-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhiLo.cpp
More file actions
38 lines (33 loc) · 855 Bytes
/
hiLo.cpp
File metadata and controls
38 lines (33 loc) · 855 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
//=====================================
//hiLo.cpp
//Plays the high low game
//=====================================
#include <iostream>
#include <cstdlib>
using namespace std;
int main(void)
{
int max=100;//max number for guessing
int seed;
cout<< "Input a seed integer please :> ";
cin>> seed;
//get a somewhat random number between zero and max;
srand(seed);
int target=rand()%(max+1);
cout<< "Guess a number between 0 and " << max << " :> ";
int guess;
cin>>guess;
while(guess!=target)
{
cout<<guess<<" < target is "<< (guess<target)
<< endl;
cout<<guess<<" > target is "<< (guess>target)
<< endl;
cout<< "Guess a number between 0 and " << max << " :> ";
cin>> guess;
}
cout<<"Congratulations. "
<<"You've just wasted a few minutes of your life";
cout<<endl;
return 0;
}