Hi,
I am running an application and wish to add random outputs when the user answers correctly.
example 1 + 1 = 2
cout << " great";
I wish to randomly cout << excellent or very good or fantastic as well. Thanks!
This is my code:
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
// function prototypes
// generateQuestion
// generateOutput
int main()
{
srand(time(0));
int num1 = 1+ rand() %10;
int num2 = 1+ rand() %10;
int product = num1 * num2;
int answer = 0;
cout << " *****Welcome to Multiplication Teacher***** " << " Enter -1 to exit " << endl << endl;
cout <<"How much does " << num1 <<" times " << num2 << " = ";
cin >> answer;
if (answer == -1)
return 0;
else if(answer == product)
{
cout <<"\nCongratulations"<< endl << endl;;
return 0;
}
while(answer != product)
{
cout <<"Invaid Entry!!! Please try again: ";
cin >> answer;
if (answer == -1)
return 0;
else if(answer == product)
{
cout <<"\nCongratulations"<< endl << endl; <----- this is where i wish to add it as a random output and not just congratulations.
return 0;
}
}
cout << endl << endl;
return 0;
}