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
31 lines (25 loc) · 727 Bytes
/
randnum.c
File metadata and controls
31 lines (25 loc) · 727 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
/*Ava N.*/
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main (){
srand(time(0));
int r=rand() %10 + 1;
/*printf("%d", r);*/ /*This was checking to make sure that only numbers 1-10 were being generated as a random.*/
int g; /*g=user's guess*/
printf("Can you guess what random number between 1-10 the computer has generated? \n");
scanf("%d", &g);
if (g==r){
printf("You're a genius! That was the correct answer! \n");
}
else if(g>r){
printf("You're number was too high! Try again next time. \n");
}
else if(g<r){
printf("You're number was too low! Try again next time. \n");
}
else {
printf("You entered an incorrect value. Try again next time. \n");
}
return 0;
}