-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
56 lines (45 loc) · 911 Bytes
/
main.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
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main() {
int i;
for (i = 1; i <= 10; i++) {
int x = rand() % 20 + 1;
int y = rand() % 20 + 1;
int z = rand() % 4;
int a=0;
printf("[%d/10]", i);
if (z == 0) {
printf("%d - %d =", x, y);
scanf_s("%d", &a);
if (a == x - y)
printf("Correct!\n");
else
printf("Wornd! Answer is %d\n", x - y);
}
if (z == 1) {
printf("%d + %d =", x, y);
scanf_s("%d", &a);
if (a == x + y)
printf("Correct!\n");
else
printf("Wornd! Answer is %d\n", x+ y);
}
if (z == 2) {
printf("%d * %d =", x, y);
scanf_s("%d", &a);
if (a == x * y)
printf("Correct!\n");
else
printf("Wornd! Answer is %d\n", x * y);
}
if (z == 3) {
printf("%d / %d =", x, y);
scanf_s("%d", &a);
if (a == x / y)
printf("Correct!\n");
else
printf("Wornd! Answer is %d\n", x / y);
}
}
}