Learn how to create a simple quiz game in C @codetek.
Code Source:
Simple Game in C
#include
int main() {
int score = 0;
printf("Welcome to the Quiz Game!\n");
printf("Question 1: What is the capital of France?\n");
printf("A) Madrid\nB) Paris\nC) Rome\nD) Berlin\n");
char answer1 = 'B';
printf("Your answer: ");
char userAnswer1;
scanf(" %c", &userAnswer1);
if (userAnswer1 == answer1) {
printf("Correct!\n");
score++;
} else {
printf("Wrong!\n");
}
// Add more questions and answers...
printf("Your score: %d out of 5\n", score);
return 0;
}