-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathguessing2.c
56 lines (40 loc) · 969 Bytes
/
guessing2.c
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
56
// Team Solid
// Brandon Lim, Christopher Narducci & Jacob Lindahl
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main()
{
srand(time(NULL));
int num = rand() % 99 + 1;
int guess;
int i = 1;
printf("I'm thinking of a number between 1-100. You have 7 guesses.\n\n");
printf("First Guess: ");
scanf("%d", &guess);
i++;
while(guess != num && i <= 7)
{
if (guess > num)
{
printf("Sorry, too high.\n\n");
}
else
{
printf("Sorry, too low.\n\n");
}
printf("Guess #%d: ", i);
scanf("%d", &guess);
i++;
}
if (guess == num)
{
printf("\nCongrats! What are the odds?!\n");
}
else
{
printf("\nSorry, you didn't guess it in 7 tries.\n");
printf("The number was %d.\n", num);
}
return 0;
}