We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 6a68b07 commit 3c76decCopy full SHA for 3c76dec
1 file changed
guessNumer.cpp
@@ -0,0 +1,31 @@
1
+#include<iostream>
2
+#include<ctime>
3
+#include<cstdlib>
4
+using namespace std;
5
+
6
+int main()
7
+{
8
+cout << "enter the range of the number : ";
9
+int range , hits ;
10
+cin >> range;
11
+cout << "\n enter the hits : ";
12
+cin >> hits ;
13
+int i = time(0);
14
+srand(i);
15
+ int num = 1 + rand()% range , guess;
16
+for(int i=0 ; i< hits ; i++)
17
18
+ cout << " \n enter the guess :";
19
+ cin >> guess;
20
+ if (guess == num+1 ||guess == num-1|| guess == num+2 ||guess == num-2 ){
21
+ cout << " too high"<< endl;}
22
+ else if(guess == num){
23
+ cout << " you got it " << endl;
24
+ break;
25
+ }
26
+ else{
27
+ cout << " too low"<< endl;}
28
29
+}
30
+ return 0;
31
0 commit comments