-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathHigh-low game in c++.
146 lines (135 loc) · 4.5 KB
/
High-low game in c++.
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#include<iostream.h>
#include<conio.h>
#include<stdlib.h>
#include<process.h>
#include<dos.h>
void main()
{
textbackground(WHITE);
textcolor(RED);
C: clrscr();
char ch,a[20],ch2;
int num=100,rnum,guess,count,ch1,c=0;
cout<<“nttt******************************”<<“nttt******************************”;
cout<<“nttt** **”<<“nttt** Welcome To High/Low Game **”<<“nttt** ________________________ **”;
cout<<“nttt** **”<<“nttt******************************”<<“nttt******************************”;
cout<<“nnnn————“<<“n Main Menu”<<“n————“<<“nnn 1.Rulesnn 2.Playnn 3.Exit”<<“nn Enter your choice(1-3):”;
cin>>ch1;
switch(ch1)
{
case 1:
{
clrscr();
cout<<“nn———————“<<“n General Description”<<“n———————“;
cout<<“nn1.The Computer picks a random number from 0 to 99.n You must try to guess the number.”;
cout<<“nn2.The Computer ask you to enter your guess.You have 8n chances to guess the number.”;
cout<<“nn3.The computer checks the number,if your guess isn less than computer’s numer than it will show a messagen that your guess is low and ask for higher number.”;
cout<<“nn4.If your guess is higher than the computer’s numbern than computer will show a message that your guess is high andn ask for lower number.”;
cout<<“nn5.If your guess is equal to the computer’s number,thann computer will print a message congratulating youn and will ask you to play the game again or exit.”;
cout<<“nn6.If you are unable to guess the number than the computern will a sorry message and ask you to play the game again or exit.”;
D: cout<<“nnn Press * to goto Main Menu:”;
cin>>ch2;
if(ch2==’*’)
{
ch2=’#’;
goto C;
}
else
goto D;
}
break;
case 2:
{
clrscr();
cout<<“nnnEnter Your Name:”;
cin>>a;
cout<<“nn”;
for(int i=0;i<=100;i+=20)
{
cout<<“Loading…….”<<i<<“%r”;
sleep(1);
}
cout<<“nnHi “<<a<<“………!!!!”;
A: if(c>0)
clrscr();
randomize();
rnum=random(num);
cout<<“nnEnter Your Guess:”;
cin>>guess;
count=8;
B: while(guess!=rnum)
{
count–;
if(guess>rnum)
{
cout<<“nn”<<guess<<” is High….!!!!aa”<<“nnNow You Have “<<count<<” chance left”;
if(count==0)
break;
cout<<“nnEnter Your Guess Again:”;
cin>>guess;
goto B;
}
if(guess<rnum)
{
cout<<“nn”<<guess<<” is Low…!!!aa”<<“nnNow You Have “<<count<<” chance left”;
if(count==0)
break;
cout<<“nnEnter Your Guess Again:”;
cin>>guess;
goto B;
}
}
if(guess==rnum)
{
cout<<“nnttCongratulation “<<a<<” You Have Done IT…….!!!!!aa”;
switch(count)
{
case 7: cout<<“nnYour Score is 100 out of 100”;
break;
case 6: cout<<“nnYour Score is 85 out of 100”;
break;
case 5: cout<<“nnYour Score is 70 out of 100”;
break;
case 4: cout<<“nnYour Score is 55 out of 100”;
break;
case 3: cout<<“nnYour Score is 40 out of 100”;
break;
case 2: cout<<“nnYour Score is 25 out of 100”;
break;
case 1: cout<<“nnYour Score is 10 out of 100”;
break;
}
}
else
cout<<“nnttSorry “<<a<<” Bad Luck……!!! Try Next Timeaaa”;
cout<<“nnWant to Play More(y/n):”;
cin>>ch;
if(ch==’y’||ch==’Y’)
{
c++;
goto A;
}
else
{
cout<<“nnnnttt @@@@@@@@ THANK YOU @@@@@@@@ nn”;
cout<<“================================================================================”;
cout<<“aanntttt Special Thanks Tontttt___________________nntttt Mrs.Rakhi Jain”;
cout<<“nnnntttt Game Developed Byntttt___________________nntttt Neeraj Mishra”;
cout<<“nn================================================================================”;
delay(10000);
exit(0);
}
}
break;
case 3:
{
cout<<“nnn================================================================================”;
cout<<“nntttt Special Thanks Tontttt___________________nntttt Mrs.Rakhi Jain”;
cout<<“nnnntttt Game Developed Byntttt___________________nntttt Neeraj Mishra”;
cout<<“nnn================================================================================”;
delay(10000);
exit(0);
}
}
getch();
}