In: Computer Science
I WANT THIS CODE TO BE SIMPLE BECAUSE I AM NEW TO CODING AND I WANT TO KNOW THE DETAILS! straight C Program. write a quiz game where a number of questions are asked and the user will win each time he answers right. and he loses each time he answers wrong.
the type of questions asked can be about sports or anything else. You can put 5 quiz questions.
It should only include the following: #include <stdio.h> and #include <stdlib.h>
because it is a simple code.
plss give like if u like answer. any question free to ask.
#include<stdio.h>
#include<stdlib.h>
int main()
{
char
ans1,ans2,ans3,ans4,ans5; //Taking
character variable for every questions correct answers.
char yans1,yans2,yans3,yans4,yans5; //Taking
character variable for your answers
printf("Welcome to Quiz/n/n");
printf("Holkar trophy associated with which
trophy?\n\n"); //"\n\n use for skip next two line
printf("A.Bridge\tB.Hockey\n\nC.Football\tD.Badminton\n\n");
ans1='A'; //here we store the correct answer of
question.
printf("Your Answer:");
scanf(" %c",&yans1); //must use space before
%c otherwise next scanf will not work.
if( ans1 == yans1) //compare correct answer with
your answer.
{
printf("\nYou Win\n\n");
//if ans correct it show you win.
}
else
{
printf("\nYou
Lose\n\n"); //if ans wrong it show you lose.
}
//same way we can do for other questions.
printf("With which game does Davis cup
associated?\n\n");
printf("A.Table
Tennis\tB.Hockey\n\nC.Polo\tD.Lawn Tennis\n\n");
ans2='D';
printf("Your Answer:");
scanf(" %c",&yans2);
if(ans2 == yans2)
{
printf("\nYou
Win\n\n");
}
else
{
printf("\nYou
Lose\n\n");
}
printf("Who is the first indian women to win an
Asian Games gold in 400m run?\n\n");
printf("A.M.L Valsamma\tB.P.T.
Usha\n\nC.kamaljit Sandhu\tD.K.Malleshwari\n\n");
ans3='B';
printf("Your Answer:");
scanf(" %c",&yans3);
if( ans3 == yans3)
{
printf("\nYou
Win\n\n");
}
else
{
printf("\nYou
Lose\n\n");
}
printf("Term chinaman is related to which
sport?\n\n");
printf("A.Football\tB.Hockey\n\nC.Golf\tD.Cricket\n\n");
ans4='D';
printf("Your Answer:");
scanf(" %c",&yans4);
if( ans4 == yans4)
{
printf("\nYou
Win\n\n");
}
else
{
printf("\nYou
Lose\n\n");
}
printf("Welling Trophy is related to which
game?\n\n");
printf("A.Rowing\tB.Hockey\n\nC.Tennis\tD.Polo\n\n");
ans5='A';
printf("Your Answer:");
scanf(" %c",&yans5);
if( ans5 == yans5)
{
printf("\nYou
Win\n\n");
}
else
{
printf("\nYou
Lose\n\n");
}
return 0;
}