Simple General Knowledge (GK) Quiz program in C

CWC
3 Min Read

Here I have created simple general knowledge (GK) Quiz program in C. In this program at first I declared integer variable x which will be our total score. Then I declared some char variable and one char array ch1[100].  Then I took name of the user using this line:

scanf("%[^\n]", ch1);

here %[^\n]  means take input string until new line.

You need to add getchar()  after taking full string because it will hold the last new line input.

Then it will print Welcome the user.

Main step for this program:

Then it will print first question and tell the user to answer the question. After entering any value then it will check if the answer is correct or not by comparing (ch2==’a’)  user input and the write answer. If the answer is correct then 10 will add with x variable and if the is not correct then it will print “Sorry wrong answer”.

system(“cls”): This function will clear the whole console. To use this function I had to include stdlib.h library.

End Main step

In this step for now I have added 11 questions for this general knowledge (GK) program.

After all questions,

If total score “x” is equal to 100, then it will print

“No cheating...... You have done this earlier also.”

If total score “x” is equal to 90, then it will print

“You are extremely intelligent. Your Score is 90”

If total score “x” is equal to 80, then it will print

“You are intelligent. Your Score is 80”

If x == 50 || x == 70 || x == 60  then it will print

“You are average. Your Score is %d. Better luck next time\n", x”

If total score “x” is equal or smaller than 40, then it will print

“No use…….. Not even 5 questions right”

Download source code for Simple General Knowledge (GK) Quiz program in C with EXE file

[sociallocker]

Download General Knowledge (GK) Quiz program in C with EXE file -codewithc
Zip Password: codewithc.com

[/sociallocker]

Share This Article
Leave a comment

Leave a Reply

Your email address will not be published. Required fields are marked *

English
Exit mobile version