Home Python C Language C ++ HTML 5 CSS Javascript Java Kotlin SQL DJango Bootstrap React.js R C# PHP ASP.Net Numpy Dart Pandas Digital Marketing

Quiz:

Certainly! Here's a simple C language quiz with multiple-choice questions. Users can select the correct option by entering the corresponding letter.

#include <stdio.h>

int main() {
int score = 0; // Initialize score

// Question 1
printf("1. What is the capital of France?\n");
printf("a) Paris\nb) London\nc) Rome\nd) Berlin\n");
char answer1;
scanf(" %c", &answer1);
if (answer1 == 'a') {
printf("Correct!\n");
score++;
} else {
printf("Incorrect!\n");
}

// Question 2
printf("\n2. What is the result of 2 + 2?\n");
printf("a) 3\nb) 4\nc) 5\nd) 6\n");
char answer2;
scanf(" %c", &answer2);
if (answer2 == 'b') {
printf("Correct!\n");
score++;
} else {
printf("Incorrect!\n");
}

// Question 3
printf("\n3. Who is known as the father of modern physics?\n");
printf("a) Isaac Newton\nb) Albert Einstein\nc) Galileo Galilei\nd) Max Planck\n");
char answer3;
scanf(" %c", &answer3);
if (answer3 == 'b') {
printf("Correct!\n");
score++;
} else {
printf("Incorrect!\n");
}

// Display final score
printf("\nYour score: %d out of 3\n", score);

return 0;
}

This quiz consists of three multiple-choice questions. After each question, the user is prompted to enter their answer by typing the corresponding letter ('a', 'b', 'c', or 'd'). The program checks whether the entered answer is correct and updates the score accordingly. Finally, it displays the user's final score out of 3.

Feel free to add more questions or customize the quiz as needed!



Advertisement





Q3 Schools : India


Online Complier

HTML 5

Python

java

C++

C

JavaScript

Website Development

HTML

CSS

JavaScript

Python

SQL

Campus Learning

C

C#

java