-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
Copy pathgg.cpp
48 lines (48 loc) · 1.17 KB
/
gg.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
#include <iostream>
#include <stdlib.h>
using namespace std;
int main()
{
int num, ran, att = 3;
int lowest = 1, highest = 10;
int range = (highest - lowest) + 1;
while (true)
{
ran = lowest + rand() % range;
while (att > 0)
{
cout << "Enter Your guess between 1 to 10 "
<< "(" << att << " chances left): ";
cin >> num;
if (num == ran)
{
cout << "Awesome!! You guessed it right!";
exit(0);
}
else
{
if (att == 1)
{
char c;
cout << "You lost!!" << endl;
cout << "Wanna try again?(y/n): ";
cin >> c;
if (c == 'n')
{
exit(0);
}
else
{
att = 3;
continue;
}
}
else
{
att--;
continue;
}
}
}
}
}