-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathguess.c
More file actions
35 lines (33 loc) · 755 Bytes
/
Copy pathguess.c
File metadata and controls
35 lines (33 loc) · 755 Bytes
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
/*
Author - hypernovaradiation
*/
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main() {
int start,stop,count,guess; int result=0;
printf("\n\nEnter the starting range :");
scanf("%d",&start);
printf("\nEnter the stopping range :");
scanf("%d",&stop);
printf("\nEnter the chances :");
scanf("%d",&count);
srand(time(NULL));
int num=rand()%(stop-start)+start;
printf("\n\n\n\nGame Start\n\n\n");
while (count>0) {
printf("\nGuess the number : ");
scanf("%d",&guess);
if (num==guess) {
result=1;
break;
} else {
printf("\n\nTry again\nChances Left : %d\n",--count);
}
}
if (result==1) {
printf("\n\nYou Guessed the number\n\n");
} else {
printf("\n\nGame Over\nThe correct number was %d\n\n",num);
}
}