-
Notifications
You must be signed in to change notification settings - Fork 82
/
Copy pathNumberGuessing.cpp
56 lines (53 loc) · 1.44 KB
/
NumberGuessing.cpp
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include <iostream>
using namespace std;
// Guessing the number game
int main()
{
// this program finds that the user selects from 1 to 8
char answer;
cout<<"pick a number from 1 to 8." << endl;
cout<<"its is less than 5 ? (y|n):";
cin>>answer;
if(answer == 'y')
{
cout<<"is it less than 3? (y|n):";
cin>>answer;
if(answer == 'y')
{
cout<<"is it less than 2 ? (y|n):";
cin>>answer;
if(answer == 'y')
cout<<"Your number is 1 "<<endl;
else cout<< "your number is 2"<<endl;
}
else
{
cout<<"is it less than 4 ? (y|n):";
cin>>answer;
if(answer == 'y')
cout<<"Your number is 3 "<<endl;
else cout<< "your number is 4"<<endl;
}
}
else
{
cout<<"is it less than 7 ? (y|n):";
cin>>answer;
if(answer == 'y')
{
cout<<"is it less than 6 ? (y|n): "<<endl;
cin>>answer;
if(answer == 'y')
cout<<"Your number is 5 "<<endl;
else cout<< "your number is 6"<<endl;
}
else
{
cout<<"is it less than 8 ? (y|n):";
cin>>answer;
if(answer == 'y')
cout<<"Your number is 7 "<<endl;
else cout<< "your number is 8"<<endl;
}
}
}