: I want this progam to loop as long as the user enters a positive
: number. If any other number is entered or q is entered to quit I
: want it to exit. For some reason it q is entered is just prints out
: forever. Any suggestions?
:
:
: #include <iostream>
: using namespace std;
:
: int main( )
: {
:
: int tablemax, tablenum, i, userInput;
:
: cout << "Enter the largest number you would like your multiplication table to test: ";
: cin >> tablemax;
:
: do
: {
: cout << "To practice your multiplication, \n";
: cout << "enter the positive number you want to practice, or enter Q to quit.\n";
:
: cout << "You will practice this number up to " << tablemax << endl;
:
: cout << "Enter a number: ";
: cin >> tablenum;
:
: int *table = new int [tablemax + 1];
:
: for (i = 0; i <= tablemax; i++)
: table[i] = tablenum * i;
:
: for (i = 0; i <= tablemax; i++)
: {
: cout << tablenum << " x " << i << " = ";
: cin >> userInput;
:
: if (userInput == table[i])
: cout << "Very good, that is the correct answer\n";
: else
: cout << "That is incorrect, the correct answer is " << table[i] << endl;
: }
:
: cout << endl;
: cout << "You have completed your multiplication tables for: " << tablenum << endl;
: cout << endl;
: }
:
: while (tablenum != 'q' || tablenum != 'Q');
:
: cout << "Goodbye!";
:
: return 0;
: }
: :
Variable "tablenum" is of integer type and you're assigning it character value.