Created
February 16, 2016 11:02
-
-
Save alonzoibarra97/a71be28ae8c974ae3230 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> | |
using namespace std; | |
int guess, ranm; | |
int cont=1; | |
int main() | |
{ | |
srand(time(NULL)); | |
ranm= 1+ rand()%100; | |
do{ | |
cout<< "Guess the number the program generates\n"; | |
cin>> guess; | |
if(guess<ranm) { | |
cout<< "Try again,you are to low\n"; cont++; | |
} | |
else { | |
if(guess>ranm){ | |
cout<< "Try again,you are to high\n";cont++; } | |
else{ | |
cout<< "you win\n"; | |
cout<< "You only tried " << cont << " times";}} | |
}while(guess != ranm); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment