``123456789101112131415161718192021222324`` ``````void QuestionOne () { cout << "Question 1:" << endl << endl; int q1x, q1y, q1vx, q1vy, q1ax, q1ay; q1x = rand() % 10 + 1; q1y = rand() % 10 + 1; q1vx = rand() % 10 + 1; q1vy = rand() % 10 + 1; cout << "Point " << q1x << ", " << q1y << "is being translated with vector <" << q1vx << ", " << q1vy << ">. What are the coordinated of the new image formed?" << endl; cout << "x = "; cin >> q1ax; cout << endl << "y = "; cin >> q1ay; cout << endl; if (q1ax == ( q1x + q1vx) && q1ay == ( q1y + q1vy)) cout << "Correct!" << endl << endl << "Next Question..."; QuestionTwo(); else cout << "Incorrect! Please try again"; QuestionOne ();``````

I am getting a problem with my else statement and when the if statement is correct it does not go on to "QuestionTwo ()" but it repeats "QuestionOne ()" Please help.
Last edited on
Compound statements need to be enclosed in braces. So put braces around lines 18 -20 and 23 - 24

It is good practice to use braces - even when there is only 1 statement inside - this will save you one day when you add more code.

 ``12345678`` ``````if (q1ax == ( q1x + q1vx) && q1ay == ( q1y + q1vy)) { cout << "Correct! \n" << "Next Question..." << endl; QuestionTwo(); } else { cout << "Incorrect! Please try again" << endl; QuestionOne (); }``````
Thanks!
Topic archived. No new replies allowed.