So, i just started coding, and i got this assignment where i need to make a code where my program has 4 tries to guess a number from 1 to 10. My program has 4 tries, and there are 3 possible inputs:
1 if it's bigger
0 if it's smaller
2 if it's equal
I tried to submit the code but it exceeded the time limit(2000ms)
As i mentioned, i am very new to coding. I wrote this code but i'm not sure if it is even on the right trail at all.
The easiest way to do what your program asks is to create a FOR LOOP that stops when the variable within equals 4, or rather, 5, but won't execute once it hits 5. Happy coding :)
You have extraneous semi-colons on lines 13 and 17 which makes your loops infinite. Get rid of those empty statements.
Note that when you do remove those empty statements, since var2 cannot change within the body of the compound statements governed by the loop conditions, the loops will either be (still) infinite or never run. You should look into that.