0

When running my "if (x == y)" getting a problem

when I run "if (x==y)" it prints BOTH conditions. what's wrong? #include <iostream> using namespace std; int main() { int score = 100; int scorewin = 100; int scorepass = 50; if (score >= scorepass){ cout << "You have enough pts to move on." << endl; if (score == scorewin ){cout << "You won! You collected all the points! Go to next level!" << endl;} } else {cout << "You do not have enough points, go back and collect more." << endl;} return 0; }

19th Jan 2018, 1:22 PM
Tajiya Baba
Tajiya Baba - avatar
3 Answers
+ 3
This is because score is equal or above scorepass and score equals to scorewin.
19th Jan 2018, 1:48 PM
Chat d'Oeuf (Baron)
Chat d'Oeuf (Baron) - avatar
+ 10
Can u insert ur code..?? well there is nothing wrong with ur code..
19th Jan 2018, 1:38 PM
šŸŒ›DTšŸŒœ
šŸŒ›DTšŸŒœ - avatar
0
Qyther, DT Yep, I just figured out what happened. Qyther is right; without an else statement to pair with the "score >= scorepass" condition, the program with print both outcomes.
19th Jan 2018, 2:33 PM
Tajiya Baba
Tajiya Baba - avatar