Another if statement question ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

Another if statement question ?

#include <iostream> using namespace std; int main() { int x, y; x = 100; y = 5000; if ( x > 99 ) { cout << "Quest Complete!\n"; y = y + 1000; cout << "Your new balance is: " << y << " "; } if ( x < 99 ) { cout << "Quest is not complete."; cout << "\n Click Here to Abandom Quest!"; } return 0; } Hey guys. Could someone clarify this part of the code for me. y=y+100-. I can't see how this is relevant ? Thanks

1st Sep 2018, 1:29 PM
harry
2 Answers
+ 9
as x>99 is true, 1000 is added to y. Y is 6000 now
1st Sep 2018, 1:30 PM
Muhd Khairul Amirin
Muhd Khairul Amirin - avatar
0
if you want the initial value to remain nd wanna increase then u have to use initial value... if u directly assign y=1000; it will only assing 1000 not 5000initial
3rd Sep 2018, 12:45 PM
Aarav Raj
Aarav Raj - avatar