![]() |
Need Help
#include <iostream>
#include <time.h> using namespace std; void main() { srand(time(0)); while (true) { int brian; int happy; int r; r = rand () %101; cout <<rand () %101 << "\n"; cout << "enter number \n" ; cin >> brian; if (brian == r) { cout << "Go you, you win\n"; } else if (r<brian){ cout << "Lower\n"; } else { cout << "Higher\n"; } } } Could anyone point out what's wrong with my code . It's meant to be a higher or lower game but it keeps generating a new number everytime? |
Re: Need Help
If you format the code correctly the problem should be obvious:
Code:
#include <iostream>Code:
r = rand () %101; |
Re: Need Help
By the way, rand() returns a new random number each time it is called, so
Code:
cout <<rand () %101 << "\n"; |
| All times are GMT +5.5. The time now is 21:23. |