TECHNICAL QUIZ PROJECT IN C

QUIZ PROJECT IN C 

#include<stdio.h>
#include<conio.h>
#include<ctype.h>
#include<stdlib.h>
#include<time.h>
#include<dos.h>

void displayscore()
 {
 char name[20];
 float s;
 FILE *f;
 system("cls");
 f=fopen("score.txt","r");
 fscanf(f,"%s%f",&name,&s);
 printf("\n\n\t\t ");
 printf("\n\n\t\t %s has secured the Highest Score %.2f",name,s);
 printf("\n\n\t\t ");
 fclose(f);
 getch();
 }
void help()
 {
 system("cls");
 printf("\n\n\n\tTHIS IS A TECHNICAL QUIZ GAME\nOFFERED BY CODE AT GLANCE");
 printf("\n\n\tthe four options provided. Your score will be calculated at the");
 printf("\n\n\tend. Remember that the more quicker you give answer the more");
 printf("\n\n\tscore you will secure. Your score will be calculated and displayed");
 printf("\n\n\tat the end and displayed. If you secure highest score, your score");
 printf("\n\n\twill be recorded ALL THE BEST");
 }
void writescoreofgame(float score, char plnm[20])
 {
 float sc;
 char nm[20];
 FILE *filepointer;
 system("cls");
 filepointer=fopen("score.txt","r");
 fscanf(filepointer,"%s%f",&nm,&sc);
 if (score>=sc)
 { sc=score;
 fclose(filepointer);
 filepointer=fopen("score.txt","w");
 fprintf(filepointer,"%s\n%.2f",plnm,sc);
 fclose(filepointer);
 }
 }
int main()
 {
 int countq,countr;
 int r,i;
 int pa;int nq[6];int w;
 float score;
 char choice;
 char playername[20];
 time_t initialtime,finaltime;
 system("cls");
 //randomize();
 mainhome:
 system("cls");
 puts("\n\t\t WELCOME TO TECHNICAL QUIZ\n\n") ;
 puts("\n\t\t********************************");
 puts("\n\t\t Enter 'S' to start game ");
 puts("\n\t\t Enter 'V' to view high score ");
 puts("\n\t\t Enter 'H' for help ");
 puts("\n\t\t Enter 'Q' to quit ");
 printf("\n\t\t*********************************\n\n\t\t ");
 choice=toupper(getch());
 if (choice=='V')
 {
 displayscore();
 goto mainhome;
 }
 else if (choice=='Q')
 exit(1);
 else if (choice=='H')
 {
 help();
 getch();
 goto mainhome;
 }
 else if(choice=='S'){
 system("cls");

printf("\n\n\n\t\t\tEnter your name...");
 printf("\n\t\t\t(only one word)\n\n\t\t\t");
 gets(playername);

home:
 system("cls");
 initialtime=time(NULL);
 countq=countr=0;
 i=1;
 start:
 srand ( time(NULL) );
 r=rand()%23+1;
 nq[i]=r;
 for (w=0;w<i;w++)
 if (nq[w]==r) goto start;

switch(r)
 {
 case 1:
 printf("\n\n The brain of any computer system is?");
 printf("\n\nA.CPU\tB.ALU\n\nC.MOUSE\tD.NONE\n\n");
 countq++;
 if (toupper(getch())=='A')
 {printf("\n\nCorrect!!!");countr++; break;}
 else
 {printf("\n\nWrong!!! The correct answer is A");break;}

case 2:
 printf("\n\n\n Which of the following computer language is used for artificial intelligence?");
printf("\n\nA.PROLOG\tB.FORTRAN2\n\nC.none\tD.COBOL\n\n");
 countq++;
 if (toupper(getch())=='A')
 {printf("\n\nCorrect!!!");countr++; break;}
 else
 printf("\n\nWrong!!! The correct answer is A.");
 break;
 case 3:
 printf("\n\n\nWhich device of computer operation dispenses with the use of the keyboard?");
 printf("\n\nA.TOUCH\tB.JOYSTICK\n\nC.LIGHTPEN\tD.MOUSE\n\n");
 countq++;
 if (toupper(getch())=='D')
 {printf("\n\nCorrect!!!");countr++; break;}
 else
 {printf("\n\nWrong!!! The correct answer is D.");break;}


 case 4:
 printf("\n\n\n A number that is used to control the form of another number is known as");
 printf("\n\nA.MASK\tB.MAP\n\nC.MARKER\tD.NONE\n\n");
 countq++;
 if (toupper(getch())=='A')
 {printf("\n\nCorrect!!!");countr++; break;}
 else
 {printf("\n\nWrong!!! The correct answer is A.");break;}


 case 5:
 printf("\n\n\nThe 2's complement of a binary no. is obtained by adding.....to its 1's complement.?");
 printf("\n\nA.1\tB.0\n\nC.10\tD.12\n\n");
 countq++;
 if (toupper(getch())=='A')
 {printf("\n\nCorrect!!!");countr++; break;}
 else
 {printf("\n\nWrong!!! The correct answer is A");break;}

case 6:
 printf("\n\n\nThe examination and changing of single bits or small groups of his within a word is called?");
 printf("\n\nA. Bit\tB.bitslice\\n\nC.bit manuplation\tD.none\n\n");
 countq++;
 if (toupper(getch())=='B' )
 {printf("\n\nCorrect!!!");countr++; break;}
 else
 {printf("\n\nWrong!!! The correct answer is B.");break;}


 case 7:
 printf("\n\n\nWhich method is used to connect a remote computer?");
 printf("\n\nA.device\tB.logic circuit\n\nC.dialup\tD.none\n\n");
 countq++;
 if (toupper(getch())=='C')
 {printf("\n\nCorrect!!!");countr++; break;}
 else
 {printf("\n\nWrong!!! The correct answer is C.");break;}


 case 8:
 printf("\n\n\nHow many bit code is used by Murray code for TELEPRINTER machines.");
 printf("\n\nA.6\tB.8\n\nC.4\tD.5\n\n");
 countq++;
 if (toupper(getch())=='D')
 {printf("\n\nCorrect!!!");countr++; break;}
 else
 {printf("\n\nWrong!!! The correct answer is D.");break;}


 case 9:
 printf("\n\n\nThe symbols used in an assembly language are?");
 printf("\n\nA.mnemonics\tB.codes\n\nC.assembler\t\tD.all\n\n");
 countq++;
 if (toupper(getch())=='A')
 {printf("\n\nCorrect!!!");countr++; break;}
 else
 {printf("\n\nWrong!!! The correct answer is A.");break;}


 case 10:
 printf("\n\n\nThe term referring to evacuating the content of some part of the machine is known as ");
 printf("\n\nA.down\tB.compiler\n\nC.dump\tD.none\n\n");
 countq++;
 if (toupper(getch())=='C')
 {printf("\n\nCorrect!!!");countr++; break;}
 else
 {printf("\n\nWrong!!! The correct answer is C.");break;}


 case 11:
 printf("\n\n\nA single packet on a data link is known as?");
 printf("\n\nA.group\tB.block\n\nC.frame\tD.path\n\n");
 countq++;
 if (toupper(getch())=='C')
 {printf("\n\nCorrect!!!");countr++; break;}
 else
 {printf("\n\nWrong!!! The correct answer is C.");break;}

case 12:
 printf("\n\n\nA common boundary between two systems is called ");
 printf("\n\nA.surface\tB.interface\n\nC.interdiction\tD.none\n\n");
 countq++;
 if (toupper(getch())=='B')
 {printf("\n\nCorrect!!!");countr++; break;}
 else
 {printf("\n\nWrong!!! The correct answer is B.");break;}

case 13:
 printf("\n\n\nA name applied by Intel corp. to high speed MOS technology is called ");
 printf("\n\nA.HMOS\tB.LAP\n\nC.HDLC\tD.NONE\n\n");
 countq++;
 if (toupper(getch())=='A')
 {printf("\n\nCorrect!!!");countr++; break;}
 else
 {printf("\n\nWrong!!! The correct answer is A.");break;}

case 14:
 printf("\n\n\nThe time for which a piece of equipment operates is called");
 printf("\n\nA.EFFECTIVE TIME\tB.SEEK TIME\n\nC.REAL TIME\tD.NONE\n\n");
 countq++;
 if (toupper(getch())=='A')
 {printf("\n\nCorrect!!!");countr++; break;}
 else
 {printf("\n\nWrong!!! The correct answer is A.");break;}

}
 i++;
 if (i<=5) goto start;
 finaltime=time(NULL);
 score=(float)countr/countq*100-difftime(finaltime,initialtime)/3;
 if (score<0) score=0;
 printf("\n\n\nYour Score: %.2f",score);
 if (score==100) printf("\n\nEXCELLENT!!! KEEP IT UP");
 else if (score>=80 && score<100) printf("\n\nVERY GOOD!!");
 else if (score>=60 &&score<80) printf("\n\nGOOD! BUT YOU NEED TO KNOW MORE.");
 else if (score>=40 && score<60) printf("\n\nSATISFACTORY RESULT, BUT THIS MUCH IS MUCH SUFFICIENT.");
 else printf("\n\nYOU ARE VERY POOR IN G.K.,WORK HARD");
 puts("\n\nNEXT PLAY?(Y/N)");
 if (toupper(getch())=='Y')
 goto home;
 else
 {
 writescoreofgame(score,playername);
 goto mainhome;
 }
 }
 else
 {
 printf("\n\n\t\t Enter the right key\n\n\t\t ");
 goto mainhome;
 }
 return 0;
}



OUTPUT:

WELCOME TO TECHNICAL QUIZ
***********************************
Enter ‘S’ to start game
Enter ‘V’ to view high score
Enter ‘H’ for help
Enter ‘Q’ to quit
*********************************

And after this Questions will appear on screen and so on …You will be navigated….!

Leave a Reply

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