+ 3
Whats wrong with this code????
4 Réponses
+ 2
Reason why it's not doing what you expect:
if(guess == r){ ... }
And not really a bug, but you should use srand to seed a starting point for rand. Else you'll get the same number every time you run the code.
+ 2
Also use else statement with if.
if(guess>r) {
//code
}
else if (guess <r){
//code
}
else {
//code
}
+ 2
I commented the changes into the code. Maybe it helps you with your learning:
https://code.sololearn.com/cbmPkQuhvbJW/?ref=app
0
thank you both of you for solving my code
btw guys if you also do same mistake hit like.