made simple guess with lives
This commit is contained in:
parent
4d5d06bf61
commit
57ae8cd836
17
c/test.c
17
c/test.c
@ -1,5 +1,18 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <wchar.h>
|
||||||
int main(void) {
|
int main(void) {
|
||||||
printf("Hello, World!\n");
|
int lives = 7;
|
||||||
return 0;
|
int questions = 20;
|
||||||
|
for (int i = 0;i < questions; i++) {
|
||||||
|
printf("You have %d lives left\n", lives);
|
||||||
|
printf("Question %d: What is 2 + 2?\n", i + 1);
|
||||||
|
int answer;
|
||||||
|
scanf("%d", &answer);
|
||||||
|
if (answer == 4) {
|
||||||
|
printf("Correct!\n");
|
||||||
|
} else {
|
||||||
|
printf("Incorrect!\n");
|
||||||
|
lives--;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user