-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNumGuessingGame.cpp
54 lines (48 loc) · 1.07 KB
/
NumGuessingGame.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
/*By Artin Moghadasi
@Artin.Projects
*/
#include <iostream>
#include <string.h>
#include <time.h>
using namespace std;
int main()
{
cout<<"WELCOME TO NUMBER GUESSING GAME!"<<endl;
while (true)
{
int guess,num,tries;
string choice;
srand(time(0));
num = (rand()%100)+1;
do
{
cout<< "Guess:";
cin>>guess;
if(guess>num)
{
cout<<"NUMBER IS LESS"<<endl;
continue;
}
else if(guess<num)
{
cout<<"NUMBER IS BIGGER" << endl;
continue;
}
else
{
cout<<"CORRECT!"<<endl;
break;
}
}
while(num != guess);
cout<<"WANT TO PLAY AGAIN?(yes/no)"<<endl;
cin>>choice;
if(choice=="YES" || "yes")
continue;
else
{
cout<<"BYE!";
break;
}
}
}