Logic errors in my program?

  • From: Jes <theeternalkid@xxxxxxxxx>
  • To: programmingblind@xxxxxxxxxxxxx
  • Date: Sun, 18 Jul 2010 03:18:06 -0400

Hi all,

After working on this program for four hours total, I finally got all the 
syntax errors out and the program runs.
It's a simple program that multiplies a number from 1 to 10, then displays the 
results. It asks the user to enter the number they want multiplied, then it 
does the multiples. After it displays the results to the screen, it is supposed 
to ask the user if they want another multiplication table displayed. If the 
user presses y, it should start all over again, and if they press n, the 
program should exit.
However, every time I run the program, it exits on me no matter what answer I 
give it. If I answer y, it exits. Can somebody take a look at this code and 
tell me what I'm doing wrong?
Thanks for any help.
Jes
***code**
//Ch8lab2.cpp
//Displays one or more multiplication tables
//Created/revised by Jes Smith on July 18, 2010
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
int main()
{
//Declare variables
char anotherTable = 0;
int multiplicand = 0;
int product = 0;
do
{
        //get the multiplicand
        cout << "Enter the multiplicand: ";
cin >> multiplicand;
//display the multiplication table
for (int multiplier = 1; multiplier <= 10; multiplier += 1)
{
product = multiplicand * multiplier;
cout << product << endl;
} //end for
cout << "Display another multiplication table? (Y/N) ";
cin >> anotherTable;
}
while (toupper(anotherTable) == 0);
return 0;

} //end of main function


Other related posts: