Skip to content

Instantly share code, notes, and snippets.

@batmantec
Created January 25, 2016 04:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save batmantec/af9e2bff8a77495a3445 to your computer and use it in GitHub Desktop.
Save batmantec/af9e2bff8a77495a3445 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int main (){
int user, random, counter;
srand(time(0));
random = rand()%101;
cout << "You have to guess the number between 1 and 100 "<<endl;
cin >> user;
for(counter=1; user!=random; counter++)
{
if(user!=random)
{
if(user>random)
cout<<"The number is to high, please try again."<<endl;
if(user<random)
cout<<"The number is to low, please try again."<<endl;
cin>>user;
}
}
if(user==random)
{
cout<<"###########################"<<endl;
cout<<"#You get the right number!#"<<endl;
cout<<"# You made it at "<<counter<<" time. #"<<endl;
cout<<"###########################"<<endl;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment