Jump to content
Sign in to follow this  
  • entries
  • comments
  • views

today was a little different

Sign in to follow this  


I got up at f**king 3:58 p.m this afternoon and im still tired [smile] i went over to my friends house and he wasn't there:( im almost halfway through my book im waiting on my dinner so i made this program

using namespace std;

int main()
int num = ((rand() % 100) + 1); //make a random number between 1 and 100
int tries = 0;
int guess;
cout<<"enter a number between 1 and 100";
cin>> guess;

if(guess > num)
cout<<"thats too high\n\n";
if(guess < num)
cout<<"thats too low\n\n";
}while(guess != num);
cout<<"you got it in"<}

and i hope my show comes on tonight.
Sign in to follow this  


Recommended Comments

you forgot to seed the random number generator


in case you've noticed that you're guessing the same number every time, this is why

Share this comment

Link to comment
. . .and put an "else" before that second if() statement. Since the second if() is irrelevent if the first succeeds, it should rightly be ignored if that's the case. Hence adding an "else" before the second if() will increase the speed of your program greatly.

Oh, and it should never take you more than seven guesses to get the right number.

Share this comment

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!