forked from CPRO-Session1/Assignment2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrandnum.c
More file actions
47 lines (36 loc) · 851 Bytes
/
Copy pathrandnum.c
File metadata and controls
47 lines (36 loc) · 851 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
36
37
38
39
40
41
42
43
44
45
46
47
//Clarke Littlejohn
//Guessing Game random number generator
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
int main(){
int r;
int guess;
int boolean=1;
srand(time(0));
r=rand();
r<1 && r>10 ? boolean=0 : boolean++;
while(boolean!=1){
r%=10;
if(r==0)
r+=10;
if(r>=1)
if(r<=10)
boolean=1;
}
printf("\nPick a number, one through ten, to see if it the same as the computer's number.\n");
scanf("%d",&guess);
if(guess==r){
printf("%d was the correct guess.\n",guess);
} else{
if(r<guess){
printf("%d was a higher value than the computer's value. Try again, also the computer might pick a different number.\n",guess);
main();
}
else{
printf("%d was a lower value than the computer's value. Try again, also the computer might pick a different number.\n",guess);
main();
}
}
return 0;
}