#include <cmath>
#include <ctime>
#include<iostream>
using namespace std;
int main()
{
srand (time(0));
int c1, c2, c3, c4, guess, guess2;
c1 = 1 + rand() % ( 9 - 1 + 1);
c2 = 1 + rand() % ( 9 - 1 + 1);
c3 = 1 + rand() % ( 9 - 1 + 1);
c4 = 1 + rand() % ( 9 - 1 + 1);
cout << c1 << " " << "X" << " " << c2 << " " << "=" << " ";
cin >> guess;
if (guess == true)
cout <<"Correct" << endl;
else
cout <<"\nWrong" << endl;
char play;
cout <<"\nWould you like to play again?(Y/N)";
cin >> play;
if (play == 'Y' || play == 'y')
cout << c3<< " " << "X" << " " << c4<< " " << "=" << " ";
cin >> guess2;
if (guess2 == true)
cout <<"Correct" << endl;
else
cout <<"\nWrong" << endl;
system("pause");
return 0;
}
so my task is to create a program that generates two random numbers 1-9 and asks the product.
so where im stuck at, lets say it generates 1 X 5 = so you would put 5 obviously. now how do i get it to say correct. since u put the right asnwer and it says wrong. i know if i were to put the 2 numbers myself instead of random generating 1 X 5 = i couldt esily just put in my if statement , if (guess == 5) cout << "correct" but since im random generating it how would i do it ?
also the program ask the user type y/n if you want to play again. if 'y' cout another problem but lets say he type 'n' for no i dont want to play again, what do i need to put so it can just close the program "press any key to continue"
hope what i said made sense.
help if you can, thanks.