27th Mar 2018, 12:20 PM
Bhushan
Bhushan - avatar
4 odpowiedzi
+ 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.
27th Mar 2018, 12:28 PM
Alex
Alex - avatar
+ 2
Also use else statement with if. if(guess>r) { //code } else if (guess <r){ //code } else { //code }
27th Mar 2018, 12:32 PM
Nilesh
Nilesh - avatar
+ 2
I commented the changes into the code. Maybe it helps you with your learning: https://code.sololearn.com/cbmPkQuhvbJW/?ref=app
27th Mar 2018, 12:41 PM
Alex
Alex - avatar
0
thank you both of you for solving my code btw guys if you also do same mistake hit like.
27th Mar 2018, 12:36 PM
Bhushan
Bhushan - avatar