Skip to content

Commit 8e58e5f

Browse files
Create Quiz Game using c language
This is my Third project using c language
1 parent 642150e commit 8e58e5f

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

Quiz Game using c language

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#include <stdio.h>
2+
3+
int main() {
4+
int score = 0;
5+
6+
printf("Welcome to the Quiz Game!\n");
7+
8+
// Question 1
9+
printf("\nQuestion 1: What is the capital of France?\n");
10+
printf("a) London\nb) Paris\nc) Berlin\nd) Madrid\n");
11+
12+
char answer1;
13+
scanf(" %c", &answer1);
14+
15+
if (answer1 == 'b' || answer1 == 'B') {
16+
printf("Correct!\n");
17+
score++;
18+
} else {
19+
printf("Wrong answer. The correct answer is b) Paris.\n");
20+
}
21+
22+
// Question 2
23+
printf("\nQuestion 2: Which planet is known as the Red Planet?\n");
24+
printf("a) Earth\nb) Mars\nc) Venus\nd) Jupiter\n");
25+
26+
char answer2;
27+
scanf(" %c", &answer2);
28+
29+
if (answer2 == 'b' || answer2 == 'B') {
30+
printf("Correct!\n");
31+
score++;
32+
} else {
33+
printf("Wrong answer. The correct answer is b) Mars.\n");
34+
}
35+
36+
// Display final score
37+
printf("\nYour final score is: %d out of 2\n", score);
38+
39+
return 0;
40+
}

0 commit comments

Comments
 (0)