Skip to content

Instantly share code, notes, and snippets.

@alonzoibarra97
Created February 16, 2016 11:02
Show Gist options
  • Save alonzoibarra97/a71be28ae8c974ae3230 to your computer and use it in GitHub Desktop.
Save alonzoibarra97/a71be28ae8c974ae3230 to your computer and use it in GitHub Desktop.
#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