C C program for the quiz game
#include<stdio.h>
int main()
{
int i,a;
char name[200]; //for player name
printf("\t\t\t\t -: ENTER A NUMBER :- \n\n");
printf("\t\t\t \n 1. START THE QUIZ : \t\t\t \n 0. QUIT THE QUIZ : \t\t\n ");
scanf(" %d",&i); //taking values for choices
switch (i)
{
case 1:
/* defining conditions for case 1 */
printf(" \n \t\t\t ENTER YOUR NAME ");
scanf(" %s",&name);
printf("\n\t\t\t PLAYER NAME IS %s",name);
printf("\n\n\t\t\t [ SELECT AND ENTER THE ANSWER NO. ]");
printf("\n\n\t\t Q1.WHAT IS THE CAPITAL OF THE INDIA ?\n");
printf(" \n\n\n\t\t 1. DELHI \n\t\t 2.MUMBAI\n\n\t");
scanf(" %d",&a);
if (a==1) // winning condition
printf(" \n\n\t\t COREECT !!!");
else if (a==2) // for wrong choice of answer
printf("\n\t\t WRONG !!!");
else // for invalid input
printf("\n\t\t INVALID !!! ");
case 0: // case 0 for quiting the game
break;
default : // if choice is not 0 or 1
printf("\n\n\t\t\t invalid input !!!!");
break;
}
return 0;
}
Watch video :https://youtu.be/sM8Lk88fPMI