Alright, Now the purpose of the program is to generate two random numbers both from the pool of 1-50 and have them come in the form of the question asking the user to input the sum. They get two tries and after that it says your wrong and prompts you to press return and the program ends. So far it seemed fine til i got the if loop. Something isn't right.
Could someone tell me what I'm doing wrong? Thanks!
Code:#include <iostream> #include <ctime> #include <cstdlib> using namespace std; int main() { srand((unsigned)time(0)); int answer; int realanswer; int random_integer1; int random_integer2; int lowest=0, highest=49; int range=(highest-lowest)+1; for(int index=0; index<1; index++){ random_integer1 = lowest+int(range*rand()/(RAND_MAX + 1.0)); endl; } { for(int index=0; index<1; index++){ random_integer2 = lowest+int(range*rand()/(RAND_MAX + 1.0)); endl; cout << "If I add " << random_integer1 << " and " << random_integer2 << " then what do I have? " << endl; cin >> answer; } { system("PAUSE"); } { if (answer == realanswer) { cout << "You are Right! " << endl; } else { if (answer != realanswer) { cout << "Whoops Try again! :" << endl; } else { if (answer == realanswer) { cout << "You are Right :" << endl; } else { if (answer != realanswer) cout << "The answer was :" << realanswer << endl; } system("PAUSE"); return 0; } } } } }