-
Notifications
You must be signed in to change notification settings - Fork 139
Expand file tree
/
Copy pathtext.cpp
More file actions
55 lines (54 loc) · 1.73 KB
/
Copy pathtext.cpp
File metadata and controls
55 lines (54 loc) · 1.73 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
//created by The Young Programmer 🏅aka NemoNet 🖥
#include <iostream>
using namespace std;
int main()
{
// here in commits max_h=99 not h=100 because here h could be (random%100)-> [0-99] so h will be 99 not h = 100
// to make h til 100 we need to find mod with 101 not 100
int attemp = 1,ans,guess=0,_won=0,h=100,l=0;
srand(time(0));
// old line ans = rand() % 100;
// new commit or new line
ans = rand() % 101;
// change ( rand() % 100 )to (rand() % 101)
cout<<"**** PLEASE READ INSTRUCTION ****"<<endl<<endl;
cout << "NemoNet will generate"<<endl<<"any random number between 0-100"<<endl;
cout<<"you have to guess the number"<<endl<<"you have 5 attempts / chanses to guess"<<endl<<endl;
cout<<"After each wrong guess NemoNet will tell you"<<endl<<"Your guess is HIGH or LOW"<<endl;
cout<<" BEST OF LUCK"<<endl;
while(attemp <= 5)
{
cout<<endl<<"attempts no. :- "<<attemp<<endl;
cout<<"enter the guess between 0 - 100 "<<endl;
cin>>guess;
if(guess < 0 || guess > 100){
cout<<"INVALID GUESS!!"<<endl;
continue;
}
else if(guess == ans){
cout<<"CONGRATULATIONS YOU WON!! your guess "<<guess<<" is correct"<<endl;
_won = 1;
break;
}
else if(guess < ans){
cout<<"*** Your guess "<<guess<<" * LOW * "<<endl;
l = guess;
}
else{
cout<<"*** Your guess "<<guess<<" * HIGH * "<<endl;
h = guess;
}
cout<<"*Number is between "<<l<<" ---to---> "<<h<<endl;
attemp++;
}//loop end
cout<<"\n";
if(_won){
cout<<"THANKS FOR PLAYING!! PLESE GIVE A STAR"<<endl;
}
else{
cout<<"Sorry you lost! correct answer is: "<<ans<<endl<<"please play again and give A STAR"<<endl;
}
cout<<"\n\n";
cout<<"You can Contact NemoNet for more programming Games :-) \n";
cout<<"https://github.com/The-Young-Programmer";
}