-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathguess.cpp
More file actions
60 lines (52 loc) · 1.21 KB
/
Copy pathguess.cpp
File metadata and controls
60 lines (52 loc) · 1.21 KB
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
57
58
59
60
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int play()
{
int user,a=1;
int random=rand() % 10;
random+=1;
cout<<"its the guessing game. guess a random number from 1 to 10\nenter your choice.lets test your luck\n ";
do
{
cout<<"enter your choice ";
// cout<<random<<"\n";
cin>>user;
if(user == random)
{
cout<<"Arent you a lucky one....😍😍😍🤩!oh u win\n\n";
a=0;
}
else if(user<random)
{
cout<<"oops too small\n";
cout<<"click 1 to just try again or just enter 0 if u dont feel like playing. \n";
cin>>a;
}
else
{
std::cout<<"oh too big\n ";
cout<<"click 1 to try again or just enter 0 if u dont feel like playing.\n";
cin>>a;
}
}while(a!=0);
}
int main() {
srand(time(NULL));
int choice;
do
{
cout<<"enter 0 to quit 1 to play\n";
cin>>choice;
switch(choice)
{
case 0 : cout<<"you exited.Come back next time!😊";
choice=0;
break;
case 1 :play();
break;
default :cout<<"wrong choice";
}
}while(choice!=0);
}