#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
#include<windows.h>
#include<mmsystem.h>
struct play {
char name[20];
int score;
}p;
void high_score();
void start();
void subject();
void help();
void red(){
printf("\033[1;31m");//red
}
void yellow(){
printf("\033[1;33m");//yellow
}
void black(){
printf("\033[1;30m");//black
}
void green(){
printf("\033[1;32m");
}
void blue(){
printf("\033[0;34m");
}
void purple(){
printf("\033[1;35m");
}
void cyan(){
printf("\033[0;36m");
}
void reset(){
printf("\033[0m");//reset
}
void main()
{
system("cls");
int chc=0;
red();
printf("\n\t\t\t **** ");
printf("\n\t\t\t ********** ");
printf("\n\t\t\t ****** WELCOME ****** ");
printf("\n\t\t\t ******* TO ****** ");
printf("\n\t\t\t QUIZ..!! ****** ");
printf("\n\t\t\t ****** ");
printf("\n\t\t\t ***** ");
printf("\n\t\t\t ***** ");
printf("\n\t\t\t ***** \n");
printf("\n\t\t\t * ");
printf("\n\t\t\t *** ");
printf("\n\t\t\t * ");
reset();
printf("\n press any key go to main menu....");
getch();
system("cls");
purple();
printf("\n\t\t\t*************** MAIN MENU ***************\n");
reset();
printf("\t\t\t____________________________________________\n");
printf("\n\t\t\tPress 1 to start the game\n\t\t\t2 to see high scores \n\t\t\t3 To see all subjects in QUIZ \n\t\t\t4 to see game help\n\t\t\t0 to exit : ");
scanf("%d",&chc);
system("cls");
switch(chc)
{
case 1:
start();
break;
case 2:
high_score();
break;
case 3:
subject();
break;
case 4:
help();
break;
default:
exit(1);
}
getch();
}
void help()
{
int ch;
red();
printf("\n\n\t\t\t\t\t * GAME HELP *");
reset();
printf("\n\t\t -------------------------------------------------------------------------");
printf("\n \t\t\t.................... Quiz Game ...................\n");
printf("\n\t\t >> There will be a total of 60 questions");
printf("\n\t\t >> You will be given 4 options and you have to press 1, 2 ,3 or 4 for the");
printf("\n\t\t right option");
printf("\n\t\t >> There will be total 2 levels containing 6 different subject and Each subject contain 10 questions");
printf("\n\t\t >> Each question will carry 5 points");
printf("\n\t\t >> After completing each subject, the score will be minimum 25 points then you will entering in the next");
printf("\n\t\t level otherwise you are not applicable for the next subject");
printf("\n\t\t >> You will be asked questions continuously.");
printf("\n\t\t >> There is no negative marking for wrong answer");
blue();
printf("\n\n\t\t\t\t\t * BEST OF LUCK *\n\n");
reset();
printf("\nContinue playing ? (1/0) : ");
scanf("%d",&ch);
if(ch==1)
{
start();
}
else
{
exit(1);
}
}
void subject()
{
int ch;
red();
printf("\n\t\t\t\t\t *subjects* ");
reset();
printf("\n\t\t -------------------------------------------------------------------");
printf("\n\t\t1. Computer Network-II\n\t\t2. Software Engineering\n\t\t3. Operating System\n\t\t4. Computer Organisation and Architechture\n\t\t5. Automata Theory\n");
printf("\nContinue playing ? (1/0) : ");
scanf("%d",&ch);
if(ch==1)
{
start();
}
else
{
exit(1);
}
}
void start()
{
int ans;
int count,count1,count2,count3,count4,count5=0;
int ch;
int choice;
int total;
int arr[]={3,1,2,3,1,4,1,1,1,2};
char s;
int i;
char que[500]="";
FILE *ptr;
FILE *fpt;
FILE *pl;
FILE *pls;
FILE *fp;
FILE *pt;
printf("\n\t\t\t\tPlease enter your name: ");
scanf("%s",p.name);
system("cls");
printf("\n\n\t\t\t\t==============================================================================");
purple();
printf("\n\t\t\t\t\t\t ** Welcome \" %s \" to Quiz Game ** ", p.name);
reset();
printf("\n\t\t\t\t==============================================================================\n");
printf("\n\t\t\t>>press 8 to start first level\n\t\t\t>>press 0 to exit\n");
scanf("%d",&choice);
system("cls");
purple();
printf("\n\t\t\t >>>>>> You are entering in First Level <<<<<<");
printf("\n\t\t\t------------------------------------------------------------------------------\n");
reset();
yellow();
printf("\n\t\t\t #COMPUTER NETWORK-I\n\n");
reset();
switch(choice)
{
{
case 8:
//FILE *ptr;
ptr=fopen("CN1que.txt","r");
if(ptr==NULL){
printf("error");
}
else{
int x=0,y=-1,ans,a=0;
while(!feof(ptr))
{
printf("%s ",que);
//fscanf(ptr,"%s",que);
fgets(que,sizeof(que),ptr);
for(i=0;i!=500;i++)
{
if(x!=0 && que[i]=='Q' && que[i+1]=='('){
printf("\t\t\t\t enter your ans : ");
scanf("\t\t\t\t%d",&ans);
y++;
if(arr[y]==ans){
green();
printf("\t\t\t\tCorrect! +5 points\n\n");
reset();
//PlaySound(TEXT("C:\\users\\vaibh\\Downloads\\171341450_1.wav"),NULL,SND_SYNC);
++count;
}
else
{
red();
printf("\t\t\t\tWrong answer! Correct answer is %d .\n\n",arr[y]);
reset();
//PlaySound(TEXT("C:\\users\\vaibh\\Downloads\\wrong-ans.wav"),NULL,SND_SYNC);
}
x++;
// break;}
}
}
x++;
if(y==9){
if(count > 0)
{
printf("\t\t\tThanks for playing, Your scored: %d points \t\n", count*5);
p.score=count*5;
if(p.score >= 25)
{
green();
printf("\n\t\t\t CONGRATULATION...!!!You are Passed in this subject..!!\n");
reset();
printf("\n press any key go to next subject");
getch();
system("cls");
}
else
{
red();
printf("\n\t\t\t Sorry..!! you are failed in Computer Network-I subject\n\n");
reset();
yellow();
printf("\t\t\t Don't feel bad...there is surprise for you..!!\n");
reset();
printf("\n press any key....");
getch();
system("cls");
yellow();
printf("\n\t\t\t >> Solve this puzzle to pass in this subject\n\n");
reset();
printf("\t\t\t\t * * * * * * * * * * * * * \n");
printf("\t\t\t\t * * * * \n");
printf("\t\t\t\t * A=2 * C=4 * E=6 * \n");
printf("\t\t\t\t * * * * * * * * * * * * * \n");
printf("\t\t\t\t * * * * \n");
printf("\t\t\t\t * F=7 * J=11 * I= ? * \n");
printf("\t\t\t\t * * * * * * * * * * * * * \n");
printf("\t\t\t\t * * * * \n");
printf("\t\t\t\t * K=12 * O=16 * R=19 * \n");
printf("\t\t\t\t * * * * * * * * * * * * * \n\n");
printf("\t\t\t\t1.15 \t2.20 \t3.10 \t4.25\n\n");
printf("\t\t\t\tYour answer: ");
scanf("%d",&ans);
if(ans==3)
{
green();
printf("\n\t\t\t BRILLIENT..!! You are very intelligent!\n");
printf("\t\t\t CONGRATULATION..!! You passed in this subject\n\n");
reset();
printf("\n Press any key go to next subject");
getch();
system("cls");
}
else
{
red();
printf("\tWrong answer! Better Luck Next Time..!!\n\n");
reset();
exit(1);
}
}
}
break;
}
}
//}
printf("\n\t\t\t----------------------------------------------------------------------------");
purple();
printf("\n\t\t\t\t\t\t ** Welcome \" %s \" to Next Subject ** ", p.name);
reset();
printf("\n\t\t\t----------------------------------------------------------------------------\n");
yellow();
printf("\n\t\t\t #DISCRETE MATHEMATICS\n\n");
reset();
int arr2[]={1,4,1,4,3,2,3,2,3,1};
pt=fopen("DMSque.txt","r");
if(pt==NULL){
printf("error");
}
else{
int x=0,y=-1,ans,count1=0;
while(!feof(pt))
{
printf("%s ",que);
//fscanf(ptr,"%s",que);
fgets(que,sizeof(que),pt);
for(i=0;i!=500;i++)
{
if(x!=0 && que[i]=='Q' && que[i+1]=='('){
printf("\t\t\t\tenter your ans : ");
scanf("\t\t\t\t%d",&ans);
y++;
if(arr2[y]==ans){
green();
printf("\t\t\t\tCorrect! +5 points\n\n");
reset();
++count1;
}
else
{
red();
printf("\t\t\t\tWrong answer! Correct answer is %d .\n\n",arr2[y]);
reset();
}
x++;
// break;}
}
}
x++;
if(y==9){
if(count1 > 0)
{
printf("\t\t\tThanks for playing, Your scored: %d points \t\n", count1*5);
p.score=count1*5;
if(p.score >= 25)
{
green();
printf("\n\t\t\t CONGRATULATION...!!!You are Passed in this subject\n");
reset();
}
else
{
red();
printf("\n\t\t\t Sorry..!! you are failed in DISCRETE MATHEMATICS subject\n\n");
reset();
yellow();
printf("\n\t\t\t Try your General knowledge..!! ");
reset();
printf("\n press any key....");
getch();
system("cls");
yellow();
printf("\n\t\t\t >>This question is extra question for passing in this subject\n");
reset();
red();
printf("\n\t\t\t\t How many runs were made by M.S.Dhoni in 2011 World Cup final ? \n");
reset();
printf("\n\t\t\t\tYour answer: Runs- ");
scanf("%d",&ans);
if(ans==91)
{
green();
printf("\t\t\t CONGRATULATION..!! You passed in this subject\n\n");
reset();
printf("\n Press any key to go next subject");
getch();
system("cls");
}
else
{
red();
printf("\tWrong answer! Better Luck Next Time..\n\n");
reset();
exit(1);
}
}
}
break;
}
}
//}
printf("\n\t\t\t----------------------------------------------------------------------------");
purple();
printf("\n\t\t\t\t\t ** Welcome \" %s \" to Next Subject ** ", p.name);
reset();
printf("\n\t\t\t----------------------------------------------------------------------------\n");
yellow();
printf("\n\t\t\t #MICROPROCESSOR\n\n");
reset();
int arr3[]={2,2,1,3,3,4,3,3,1,3};
fpt=fopen("MPque.txt","r");
if(fpt==NULL){
printf("error");
}
else{
int x=0,y=-1,ans,count2=0;
while(!feof(fpt))
{
printf("%s ",que);
//fscanf(ptr,"%s",que);
fgets(que,sizeof(que),fpt);
for(i=0;i!=500;i++)
{
if(x!=0 && que[i]=='Q' && que[i+1]=='('){
printf("\t\t\t\t enter your ans : ");
scanf("\t\t\t\t%d",&ans);
y++;
if(arr3[y]==ans){
green();
printf("\t\t\t\tCorrect! +5 points\n\n");
reset();
++count2;
}
else
{
red();
printf("\t\t\t\tWrong answer! Correct answer is %d .\n\n",arr3[y]);
reset();
}
x++;
// break;}
}
}
x++;
if(y==9){
if(count2 > 0)
{
printf("\t\t\tThanks for playing, Your scored: %d points \t\n", count2*5);
p.score=count2*5;
if(p.score >= 25)
{
printf("\n\t\t\t CONGRATULATION...!!!You are Passed in this subject\n");
}
else
{
red();
printf("\n\t\t\t Sorry..!! you are failed in Microprocessor subject\n\n");
reset();
yellow();
printf("\t\t\t There is extra question for you to enter the next level..!!\n");
reset();
printf("\n press any key....");
getch();
system("cls");
yellow();
printf("\n\t\t\t >>This question is extra question for passing in this subject\n");
reset();
red();
printf("\n\t\t\t\t 8085 microprocessor has how many pins- \n\t\t\t\t 1. 41 \t2. 39 \t3. 30 \t4. 40\n\n");
reset();
printf("\t\t\t\tYour answer: ");
scanf("%d",&ans);
if(ans==4)
{
green();
printf("\t\t\t CONGRATULATION..!! Luck is your side..You passed in this subject\n\n");
reset();
printf("\n Press any key to go next subject");
getch();
system("cls");
}
else
{
red();
printf("\tWrong answer! Correct answer is 4. 40\n\n");
reset();
exit(1);
}
}
}
break;
}
}
total= (count + count1 + count2)*5;
blue();
printf("\n\t\t\t\t\t--------------------------\n");
printf("\t\t\t\t\t total score is %d\n",total);
printf("\t\t\t\t\t----------------------------\n");
reset();
green();
printf("***CONGRATULATION.....!!!!!! YOU HAVE COMPLETED FIRST LEVEL..\n");
reset();
printf("\n Press any number from 0 to 9 to start the next level");
scanf("%d",&total);
}
} //}
}
printf("\n\t\t\t----------------------------------------------------------------------------");
purple();
printf("\n\t\t\t\t** Welcome \" %s \" to Next Level ** ", p.name);
reset();
printf("\n\t\t\t----------------------------------------------------------------------------\n");
yellow();
printf("\n\t\t\t #COMPUTER NETWORK-II\n\n");
reset();
int arr4[]={3,1,2,3,1,4,1,1,1,2};
pl=fopen("CN2que.txt","r");
if(pl==NULL){
printf("error");
}
else{
int x=0,y=-1,ans,count3=0;
while(!feof(pl))
{
printf("%s ",que);
//fscanf(ptr,"%s",que);
fgets(que,sizeof(que),pl);
for(i=0;i!=500;i++)
{
if(x!=0 && que[i]=='Q' && que[i+1]=='('){
printf("\t\t\t\t enter your ans : ");
scanf("\t\t\t\t%d",&ans);
y++;
if(arr4[y]==ans){
green();
printf("\t\t\t\tCorrect! +5 points\n\n");
reset();
++count3;
}
else
{
red();
printf("\t\t\t\tWrong answer! Correct answer is %d .\n\n",arr4[y]);
reset();
}
x++;
// break;}
}
}
x++;
if(y==9){
if(count3 > 0)
{
printf("\t\t\tThanks for playing, Your scored: %d points \t", count3*5);
p.score=count3*5;
if(p.score >= 25)
{
green();
printf("\n\t\t\t CONGRATULATION...!!!You are Passed in this subject\n");
reset();
}
else
{
red();
printf("\n\t\t\t Sorry..!! you are failed in Microprocessor subject");
reset();
printf("\n press any key....");
getch();
system("cls");
yellow();
printf("\n\t\t\t >>This question is extra question for passing in this subject\n");
reset();
red();
printf("\n\t\t\t\t When was IPv6 launched \n\t\t\t\t 1.June 2,2012 \t2. June 4,2012 \t3. June 5,2012 \t4. June 6,2012\n\n");
reset();
printf("\t\t\t\tYour answer: ");
scanf("%d",&ans);
if(ans==4)
{
green();
printf("\t\t\t congratulation..!! Luck is your side..You passed in this subject\n\n");
reset();
printf("\n Press any key to go next subject");
getch();
system("cls");
}
else
{
red();
printf("\tWrong answer! Correct answer is 4. June 6,2012\n\n");
reset();
exit(1);
}
}
}
break;
}
}
// }
printf("\n\t\t\t----------------------------------------------------------------------------");
purple();
printf("\n\t\t\t\t** Welcome \" %s \" to Next Level ** ", p.name);
reset();
printf("\n\t\t\t----------------------------------------------------------------------------\n");
yellow();
printf("\n\t\t\t #OPERATING SYSTEM\n\n");
reset();
int arr5[]={3,3,3,4,1,3,1,1,1,1};
pls=fopen("OSque.txt","r");
if(pls==NULL){
printf("error");
}
else{
int x=0,y=-1,ans,count4=0;
while(!feof(pls))
{
printf("%s ",que);
//fscanf(ptr,"%s",que);
fgets(que,sizeof(que),pls);
for(i=0;i!=500;i++)
{
if(x!=0 && que[i]=='Q' && que[i+1]=='('){
printf("\t\t\t\t enter your ans : ");
scanf("\t\t\t\t%d",&ans);
y++;
if(arr5[y]==ans){
green();
printf("\t\t\t\tCorrect! +5 points\n\n");
reset();
++count4;
}
else
{
red();
printf("\t\t\t\tWrong answer! Correct answer is %d .\n\n",arr5[y]);
reset();
}
x++;
// break;}
}
}
x++;
if(y==9){
if(count4 > 0)
{
printf("\t\t\tThanks for playing, Your scored: %d points \t", count4*5);
p.score=count4*5;
if(p.score >= 25)
{
green();
printf("\n\t\t\t CONGRATULATION...!!!You are Passed in this subject\n");
reset();
}
else
{
red();
printf("\n\t\t\t Sorry..!! you are failed in Microprocessor subject");
reset();
printf("\n press any key....");
getch();
system("cls");
yellow();
printf("\n\t\t\t >>This question is extra question for passing in this subject\n");
reset();
red();
printf("\n\t\t\t\t Which is the first program run on a computer when the computer boots up? \n\t\t\t\t 1. System Software \t2. Operating System \t3. System Operation \t4. None\n\n");
reset();
printf("\t\t\t\tYour answer: ");
scanf("%d",&ans);
if(ans==2)
{
green();
printf("\t\t\t congratulation..!! Luck is your side..You passed in this subject\n\n");
reset();
printf("\n Press any key to go next subject");
getch();
system("cls");
}
else
{
red();
printf("\tWrong answer! Correct answer is 2. Operating System\n\n");
reset();
exit(1);
}
}
}
break;
}
}
//}
printf("\n\t\t\t----------------------------------------------------------------------------");
purple();
printf("\n\t\t\t\t** Welcome \" %s \" to Next Level ** ", p.name);
reset();
printf("\n\t\t\t----------------------------------------------------------------------------\n");
yellow();
printf("\n\t\t\t #SOFTWARE ENGINEERING\n\n");
reset();
int arr6[]={2,3,1,2,1,4,3,2,3,2};
pls=fopen("SEque.txt","r");
if(pls==NULL){
printf("error");
}
else{
int x=0,y=-1,ans,count5=0;
while(!feof(pls))
{
printf("%s ",que);
//fscanf(ptr,"%s",que);
fgets(que,sizeof(que),pls);
for(i=0;i!=500;i++)
{
if(x!=0 && que[i]=='Q' && que[i+1]=='('){
printf("\t\t\t\t enter your ans : ");
scanf("\t\t\t\t%d",&ans);
y++;
if(arr6[y]==ans){
green();
printf("\t\t\t\tCorrect! +5 points\n\n");
reset();
++count5;
}
else
{
red();
printf("\t\t\t\tWrong answer! Correct answer is %d .\n\n",arr5[y]);
reset();
}
x++;
// break;}
}
}
x++;
if(y==9){
if(count5 > 0)
{
printf("\t\t\tThanks for playing, Your scored: %d points \t", count5*5);
p.score=count5*5;
if(p.score >= 25)
{
green();
printf("\n\t\t\t CONGRATULATION...!!!You are Passed in this subject\n");
reset();
}
else
{
red();
printf("\n\t\t\t Sorry..!! you are failed in Microprocessor subject");
reset();
printf("\n press any key....");
getch();
system("cls");
yellow();
printf("\n\t\t\t >>This question is extra question for passing in this subject\n");
reset();
red();
printf("\n\t\t\t\t Which of the following prototypes does not associated with prototyping model \n\t\t\t\t 1. Domain Prototype \t2. Vertical Prototype \t3. Horizontal Prototype \t4. Diagonal Prototype\n\n");
reset();
printf("\t\t\t\tYour answer: ");
scanf("%d",&ans);
if(ans==4)
{
green();
printf("\t\t\t congratulation..!! Luck is your side..You passed in this subject\n\n");
reset();
printf("\n Press any key to go next subject");
getch();
system("cls");
}
else
{
red();
printf("\tWrong answer! Correct answer is 4. Diagonal Prototype\n\n");
reset();
exit(1);
}
}
}
break;
}
}
//}
total=(count3 + count4 + count5)*5;
blue();
printf("\t\t\t\t----------------------------");
printf("\t\t\t\t total score is %d",total);
printf("\t\t\t\t----------------------------");
reset();
printf("\n\n\t\t\t\t\t ==================================");
printf("\n\t\t\t\t\t <<<<<<<<<<< THANK YOU.!! >>>>>>>>>");
printf("\n\t\t\t\t\t ==================================");
scanf("%d",&total);
}
}
}
break;
}
break;
default:
exit(1);
}//end switch
/*total=(count + count1 + count2 + count3 + count4+count5)*5;
printf("----------------------------");
blue();
printf("\ntotal score is %d",total);
reset();
printf("\n----------------------------\n\n");
purple();
printf("\n\n\t\t\t\t\t ==================================");
printf("\n\t\t\t\t\t <<<<<<<<<<< THANK YOU.!! >>>>>>>>>");
printf("\n\t\t\t\t\t ==================================");
reset();
scanf("%d",&total);
total =(count*5)+(count1*5)+(count2*5)+(count3*5)+(count4*5);
blue();
printf("total score is %d+%d+%d+%d+%d=%d",count,count1,count2,count3,count4,total);
reset();
scanf("%d%d%d%d%d%d",&count,&count1,&count2,&count3,&count4,&total);
counting number of correct answers and, ratings
/*if(count > 0)
{
printf("Thanks for playing, Your scored: %d points \t", count*5);
p.score=count*5;
if(p.score >= 80)
{
printf("Rating: * * * * *");
p.rat=5;
}
else if(p.score >= 60 && p.score < 80)
{
printf("Rating: * * * *");
p.rat=4;
}
else if(p.score >= 40 && p.score < 60)
{
printf("Rating: * * *");
p.rat=3;
}
else if(p.score >= 20 && p.score < 40)
{
printf("Rating: * *");
p.rat=2;
}
else if(p.score < 20)
{
printf("Rating: *");
p.rat=1;
}
//writing to file
fprintf(fp,"%s %d %d", p.name,p.score,p.rat);
fclose(fp);
}
else
{
printf("Try again!");
}*/
}
void high_score()
{
int ch;
int total;
FILE *fq;
if((fq=fopen("score.txt", "ab+"))==NULL)
{
//printf("error opening file\n");
printf("\nNo games played yet!\n");
}
else
{
printf("\n** HIGH SCORES **\n\n");
printf("NAME POINTS \n");
while(fscanf(fq,"%s %d ",p.name,total) !=EOF)
{
printf("__\n");
printf("%s %d \n\n",p.name,total);
}
fclose(fq);
}
printf("\nContinue playing ? (1 - Yes and 0 - No) : ");
scanf("%d",&ch);
if(ch==1)
{
start();
}
else
{
exit(1);
}
}