-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path22_ImplementAll_Game.cpp
More file actions
118 lines (113 loc) · 2.27 KB
/
Copy path22_ImplementAll_Game.cpp
File metadata and controls
118 lines (113 loc) · 2.27 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
// RANDOM NUMBER GAME
#include<iostream>
#include<string>
#include<cstdlib>
#include<ctime>
using namespace std;
int start()
{
cout<< "0. Quit\n1. Play Game\n";
int choice;
cin>> choice;
return choice;
}
int step(int choice)
{
if(choice==1)
{
cout<< "Yo let's play\n";
}
else if(choice==0)
{
cout<< "Thanks for playing!!\n";
return 0;
}
else
{
cout<< "Please Enter a valid number: \n";
}
return 0;
}
int game()
{
int random= rand()%100;
cout<< "You have 10 chances\n";
cout<< "Guess the number: ";
int guess, count=0;
for(int i=0; i<10; i++)
{
count++;
cin>> guess;
if(guess==random)
{
cout<< "You Won\n-----Winner-----";
break;
}
else if(i==9)
{
cout<< "Better luck next time\n";
}
else if(guess==random/2)
{
cout<< "HINT: You have won half the battle\n";
}
else if(guess>random)
{
cout<< "You have come too far\n";
}
else if(guess==random/4 && guess==random-4 && guess==random+4)
{
cout<< "HINT: May the FOURTH be with you\n";
}
else if(guess>random-20 && guess<random+20)
{
cout<< "HINT: Steave Carell got waxed in this movie\n";
}
else if(guess==random-7)
{
cout<< "You need Ariana Grande's RINGS\n";
}
else if(guess<random-100)
{
cout<< "Not even in 100 yards!\n";
}
else if(guess>random-21 && guess<random)
{
cout<< "HINT: Within length of cricket pitch\n";
}
else
{
cout<< "Not even near\n";
}
}
cout << "Wanna try again??\n";
int x=start();
step(x);
if(x==1)
{
game();
}
if(x==0)
{
return 0;
}
return 0;
}
int main()
{
srand(time(NULL));
int x=start();
step(x);
if(x==1)
{
game();
}
else if(x==0)
{
return 0;
}
else
{
cout<< "Enter Valid no: \n";
}
}