Created
January 25, 2016 04:55
-
-
Save batmantec/af9e2bff8a77495a3445 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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