Code:
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <conio.h>
#include <windows.h>
typedef struct{
char name[128];
char lname[128];
int score;
}pangalan;
int main ()
{
FILE *chan;
double diff = 0.0;
time_t start;
time_t stop;
char buff[128];
char buffer[300];
int correct=0,wrong=0,i=0;
int players;
char q1[]="amphibians",q2[]="salt",q3[]="insects",q4[]="soil",q5[]="frequency",q6[]="amino acids",q7[]="4",q8[]="monitor",q9[]="central processing unit",q10[]="cookie";
char q11[]="downloading",q12[]="tmp",q13[]="internet relay chat",q14[]="8",q15[]="internet protocol",q16[]="looping",q17[]="switch case",q18[]="luzon",q19[]="tagalog",q20[]="alibata";
char q21[]="manila",q22[]="area",q23[]="australia",q24[]="japan",q25[]="tabuk",q26[]="jupiter",q27[]="google",q28[]="monkey d. luffy",q29[]="facebook",q30[]="cannis familiaris";
char q31[]="lupang hinirang",q32[]="inland taipan",q33[]="pacman",q34[]="force",q35[]="platypus",q36[]="chronos",q37[]="cerberus",q38[]="flash",q39[]="fibonacci",q40[]="sauron";
char q41[]="patrick",q42[]="juan luna",q43[]="chlorophyll",q44[]="blue whale",q45[]="exe",q46[]="agapito flores",q47[]="graham bell",q48[]="steve jobs",q49[]="15",q50[]="Bembemboo";
char qq[80];
char choice;
pangalan daw[100];
Menu:
printf("\n\nWhat do you want to do?");
printf("\n[A]Start Exam");
printf("\n[B]Score List");
printf("\n[C]Show Answers");
printf("\n>> ");
choice=getche();
switch(choice){
case 'A': case 'a':
chan=fopen("chan.txt","a");
if(!chan){
printf("Error on opening file!\n");
return 1;
}
printf("\n\nPlease enter your first name: ");
gets(daw[i].name);
printf("Please enter your last name: ");
gets(daw[i].lname);
printf("\n\nInstructions");
printf("\nAll answers should be in lowercase");
printf("\nWrong spelling is wrong");
printf("\nGoodluck in your exam %s %s\n",daw[i].name,daw[i].lname);
system("pause");
printf("\nStarting in 5 seconds\n");
sleep(1000);
printf("Starting in 4 seconds\n");
sleep(1000);
printf("Starting in 3 seconds\n");
sleep(1000);
printf("Starting in 2 seconds\n");
sleep(1000);
printf("Starting in 1 seconds\n");
sleep(1000);
printf("GO!\n\n");
sleep(500);
time(&start);
printf("\nFrogs belong to which animal group?\n");
printf("Your answer is:\t");
gets(qq);
if((strcmp(q1,qq)==0)){
correct=correct+1;
}
else{
wrong=wrong+1;
}
printf("\nNaCl is also called?\n");
printf("Your answer is:\t");
gets(qq);
if((strcmp(q2,qq)==0)){
correct=correct+1;
}
else{
wrong=wrong+1;
}
printf("\nEtnomology is the the study of?\n");
printf("Your answer is:\t");
gets(qq);
if((strcmp(q3,qq)==0)){
correct=correct+1;
}
else{
wrong=wrong+1;
}
printf("\nPlants receive their nutrients mainly from?\n");
printf("Your answer is:\t");
gets(qq);
if((strcmp(q4,qq)==0)){
correct=correct+1;
}
else{
wrong=wrong+1;
}
printf("\nPa(Pascal) is the unit for?\n");
printf("Your answer is:\t");
gets(qq);
if((strcmp(q5,qq)==0)){
correct=correct+1;
}
else{
wrong=wrong+1;
}
printf("\nPlants synthesis protein from?\n");
printf("Your answer is:\t");
gets(qq);
if((strcmp(q6,qq)==0)){
correct=correct+1;
}
else{
wrong=wrong+1;
}
printf("\nHow many blocks does the IP address have?\n");
printf("Your answer is:\t");
gets(qq);
if((strcmp(q7,qq)==0)){
correct=correct+1;
}
else{
wrong=wrong+1;
}
printf("\nCRT(Cathode Ray Tubes) are usually found in what computer parts?\n");
printf("Your answer is:\t");
gets(qq);
if((strcmp(q8,qq)==0)){
correct=correct+1;
}
else{
wrong=wrong+1;
}
printf("\nCPU stands for?\n");
printf("Your answer is:\t");
gets(qq);
if((strcmp(q9,qq)==0)){
correct=correct+1;
}
else{
wrong=wrong+1;
}
printf("\nIt is an HTTP header that consists of text-only data saved on your computer.\n");
printf("Your answer is:\t");
gets(qq);
if((strcmp(q10,qq)==0)){
correct=correct+1;
}
else{
wrong=wrong+1;
}
printf("\nIt also refers to retrieving a file from another computer over the internet.\n");
printf("Your answer is:\t");
gets(qq);
if((strcmp(q11,qq)==0)){
correct=correct+1;
}
else{
wrong=wrong+1;
}
printf("\nWhat is the file extension of a temporary windows files?\n");
printf("Your answer is:\t");
gets(qq);
if((strcmp(q12,qq)==0)){
correct=correct+1;
}
else{
wrong=wrong+1;
}
printf("\nIRC stands for?\n");
printf("Your answer is:\t");
gets(qq);
if((strcmp(q13,qq)==0)){
correct=correct+1;
}
else{
wrong=wrong+1;
}
printf("\nHow many bits are there in a bite?\n");
printf("Your answer is:\t");
gets(qq);
if((strcmp(q14,qq)==0)){
correct=correct+1;
}
else{
wrong=wrong+1;
}
printf("\nIP is short for?\n");
printf("Your answer is:\t");
gets(qq);
if((strcmp(q15,qq)==0)){
correct=correct+1;
}
else{
wrong=wrong+1;
}
printf("\nIt is used to repeat a series of codes in programming until a condition is met.\n");
printf("Your answer is:\t");
gets(qq);
if((strcmp(q16,qq)==0)){
correct=correct+1;
}
else{
wrong=wrong+1;
}
printf("\nIt can be used to replace the if-else statement.\n");
printf("Your answer is:\t");
gets(qq);
if((strcmp(q17,qq)==0)){
correct=correct+1;
}
else{
wrong=wrong+1;
}
printf("\nWhat is the largest island in the Philippines?\n");
printf("Your answer is:\t");
gets(qq);
if((strcmp(q18,qq)==0)){
correct=correct+1;
}
else{
wrong=wrong+1;
}
printf("\nWhat is our national language?\n");
printf("Your answer is:\t");
gets(qq);
if((strcmp(q19,qq)==0)){
correct=correct+1;
}
else{
wrong=wrong+1;
}
printf("\nWhat is our ancestor's language?\n");
printf("Your answer is:\t");
gets(qq);
if((strcmp(q20,qq)==0)){
correct=correct+1;
}
else{
wrong=wrong+1;
}
printf("\nWhat is the capital of the Philippines?\n");
printf("Your answer is:\t");
gets(qq);
if((strcmp(q21,qq)==0)){
correct=correct+1;
}
else{
wrong=wrong+1;
}
printf("\nThe Homolographic project has the correct representation of\n");
printf("Your answer is:\t");
gets(qq);
if((strcmp(q22,qq)==0)){
correct=correct+1;
}
else{
wrong=wrong+1;
}
printf("\nThe great Victoria desert is located at?\n");
printf("Your answer is:\t");
gets(qq);
if((strcmp(q23,qq)==0)){
correct=correct+1;
}
else{
wrong=wrong+1;
}
printf("\nThe country which occupied the Philippines in World War II is?\n");
printf("Your answer is:\t");
gets(qq);
if((strcmp(q24,qq)==0)){
correct=correct+1;
}
else{
wrong=wrong+1;
}
printf("\nThe capital of the province of Kalinga is?\n");
printf("Your answer is:\t");
gets(qq);
if((strcmp(q25,qq)==0)){
correct=correct+1;
}
else{
wrong=wrong+1;
}
printf("\nThe largest planet in the Milky Way Galaxy is?\n");
printf("Your answer is:\t");
gets(qq);
if((strcmp(q26,qq)==0)){
correct=correct+1;
}
else{
wrong=wrong+1;
}
printf("\nWhat is the most common search engine being used in the internet?\n");
printf("Your answer is:\t");
gets(qq);
if((strcmp(q27,qq)==0)){
correct=correct+1;
}
else{
wrong=wrong+1;
}
printf("\nWho is the main character in the anime One Piece?\n");
printf("Your answer is:\t");
gets(qq);
if((strcmp(q28,qq)==0)){
correct=correct+1;
}
else{
wrong=wrong+1;
}
printf("\nWhat is the most popular social networking site?\n");
printf("Your answer is:\t");
gets(qq);
if((strcmp(q29,qq)==0)){
correct=correct+1;
}
else{
wrong=wrong+1;
}
printf("\nWhat is the scientific name of dog?\n");
printf("Your answer is:\t");
gets(qq);
if((strcmp(q30,qq)==0)){
correct=correct+1;
}
else{
wrong=wrong+1;
}
printf("\nWhat is our national anthem?\n");
printf("Your answer is:\t");
gets(qq);
if((strcmp(q31,qq)==0)){
correct=correct+1;
}
else{
wrong=wrong+1;
}
printf("\nWhat is the name of the snake that have the most toxic venom in the world?\n");
printf("Your answer is:\t");
gets(qq);
if((strcmp(q32,qq)==0)){
correct=correct+1;
}
else{
wrong=wrong+1;
}
printf("\nManny Pacquiao is also known as the name of the game that Namco has invented and it is called?\n");
printf("Your answer is:\t");
gets(qq);
if((strcmp(q33,qq)==0)){
correct=correct+1;
}
else{
wrong=wrong+1;
}
printf("\nIt is any influence that causes an object to undergo a certain change\n");
printf("Your answer is:\t");
gets(qq);
if((strcmp(q34,qq)==0)){
correct=correct+1;
}
else{
wrong=wrong+1;
}
printf("\nWhat is the only animal mammal that can lay eggs?\n");
printf("Your answer is:\t");
gets(qq);
if((strcmp(q35,qq)==0)){
correct=correct+1;
}
else{
wrong=wrong+1;
}
printf("\nWho is the god of time?\n");
printf("Your answer is:\t");
gets(qq);
if((strcmp(q36,qq)==0)){
correct=correct+1;
}
else{
wrong=wrong+1;
}
printf("\nWho is the multi-headed hound which guards the gates of the underworld?\n");
printf("Your answer is:\t");
gets(qq);
if((strcmp(q37,qq)==0)){
correct=correct+1;
}
else{
wrong=wrong+1;
}
printf("\nWho is the superhero who have a super speed with the symbol of a lightning?\n");
printf("Your answer is:\t");
gets(qq);
if((strcmp(q38,qq)==0)){
correct=correct+1;
}
else{
wrong=wrong+1;
}
printf("\nWhat do you call this sequence? 1 1 2 3 5 8 13 21\n");
printf("Your answer is:\t");
gets(qq);
if((strcmp(q39,qq)==0)){
correct=correct+1;
}
else{
wrong=wrong+1;
}
printf("\nWhat is the name of the tower in the Lord of the Rings?\n");
printf("Your answer is:\t");
gets(qq);
if((strcmp(q40,qq)==0)){
correct=correct+1;
}
else{
wrong=wrong+1;
}
printf("\nWho is the bestfriend of Spongebob SquarePants?\n");
printf("Your answer is:\t");
gets(qq);
if((strcmp(q41,qq)==0)){
correct=correct+1;
}
else{
wrong=wrong+1;
}
printf("\nWho painted the Spolarium?\n");
printf("Your answer is:\t");
gets(qq);
if((strcmp(q42,qq)==0)){
correct=correct+1;
}
else{
wrong=wrong+1;
}
printf("\nIt is a green pigment found in cyanobacteria and the chloroplasts of algae and plants.\n");
printf("Your answer is:\t");
gets(qq);
if((strcmp(q43,qq)==0)){
correct=correct+1;
}
else{
wrong=wrong+1;
}
printf("\nWhat is the biggest mammal in the world?\n");
printf("Your answer is:\t");
gets(qq);
if((strcmp(q44,qq)==0)){
correct=correct+1;
}
else{
wrong=wrong+1;
}
printf("\nWhat is the extension name of a normal program?\n");
printf("Your answer is:\t");
gets(qq);
if((strcmp(q45,qq)==0)){
correct=correct+1;
}
else{
wrong=wrong+1;
}
printf("\nWho invented the Flourescent Lamp?\n");
printf("Your answer is:\t");
gets(qq);
if((strcmp(q46,qq)==0)){
correct=correct+1;
}
else{
wrong=wrong+1;
}
printf("\nWho invented the telephone?\n");
printf("Your answer is:\t");
gets(qq);
if((strcmp(q47,qq)==0)){
correct=correct+1;
}
else{
wrong=wrong+1;
}
printf("\nWho is the founder of Apple Company?\n");
printf("Your answer is:\t");
gets(qq);
if((strcmp(q48,qq)==0)){
correct=correct+1;
}
else{
wrong=wrong+1;
}
printf("\nHow many is the total number of people who became the president of the Philippines?\n");
printf("Your answer is:\t");
gets(qq);
if((strcmp(q49,qq)==0)){
correct=correct+1;
}
else{
wrong=wrong+1;
}
printf("\nIRC stands for?\n");
printf("Your answer is:\t");
gets(qq);
if((strcmp(q50,qq)==0)){
correct=correct+1;
}
else{
wrong=wrong+1;
}
time(&stop);
diff = difftime(stop, start);
printf("\nCalculating results\n");
sleep(500);
printf("\n.");
sleep(500);
printf("\n..");
sleep(500);
printf("\n...");
printf("\n\nName: %s %s",daw[i].name,daw[i].lname);
printf("\nYour correct answers:\t%d\n",correct);
printf("Your wrong answers:\t%d\n",wrong);
printf("It took you %g seconds to finish the exam..\n",diff);
daw[i].score=correct;
fprintf(chan,"%s %s,%d\n",daw[i].name,daw[i].lname,daw[i].score);
fclose(chan);
sleep(3000);
printf("\nDo you want to return to the main menu?");
printf("\nY or N: ");
choice=getche();
switch(choice){
case 'Y': case 'y':
goto Menu;
break;
case 'N': case 'n':
printf("\n\nClosing Program");
break;
default:
printf("\n\nInvalid Choice");
break;
}
break;
case 'B': case 'b':
chan=fopen("chan.txt","r+");
if(!chan) {
printf("Error opening file!\n");
return 1;
}
i=0;
while(fgets(buffer, sizeof(buffer), chan))
{
sscanf(buffer, "%s %[^,],%d",daw[i].name,daw[i].lname,daw[i].score);
printf("\n\nName: %s %s\nScore: %d\n\n",daw[i].name,daw[i].lname,daw[i].score);
++i;
}
players=i;
fclose(chan);
printf("\n\nNumber of examinees: %d",players);
printf("\n\nDo you want to return to the main menu?");
printf("\nY or N: ");
choice=getche();
switch(choice){
case 'Y': case 'y':
goto Menu;
break;
case 'N': case 'n':
printf("\n\nClosing Program");
break;
default:
printf("\n\nInvalid Choice");
break;
}
break;
break;
case 'C': case 'c':
printf("\n\nBembemboo");
break;
default:
printf("\n\nInvalid Choice");
break;
}
getch();
}
chan.txt contains