0% found this document useful (0 votes)
205 views54 pages

Abubakar C++ Project

This document describes a quiz game project that includes: 1) Two rounds - a warm-up round with 3 simple questions and a challenge round that asks continuous questions until $1 million is earned. 2) Functions like edit_score() that tracks the cash prize and show_record() to view high scores. 3) The project is divided into student and teacher/staff accounting sections for adding, searching, modifying, and deleting records and calculating fees and salaries.

Uploaded by

Shafiu Sani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
205 views54 pages

Abubakar C++ Project

This document describes a quiz game project that includes: 1) Two rounds - a warm-up round with 3 simple questions and a challenge round that asks continuous questions until $1 million is earned. 2) Functions like edit_score() that tracks the cash prize and show_record() to view high scores. 3) The project is divided into student and teacher/staff accounting sections for adding, searching, modifying, and deleting records and calculating fees and salaries.

Uploaded by

Shafiu Sani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 54

Department of Information Technology

Data Structure and Algorithm

A
Project Report on
Quiz Game
Submitted
In partial fulfillment
For the Award of the Degree of
B.Sc. IT IV SEM.
By

Abubakar Aliko Muhammad


SID: 57966

Under the Supervision of:

Dr. Devesh Bandil

Page | 1
Introduction Quiz Game

In this quiz game project, you can store the user name, view the highest score secured by a user,
and even reset the score. Additionally, to make the game look a little more interesting, it is
divided into two rounds; user must pass the first round to reach the second one.

Of the 2 rounds I mentioned above, the first is called the Warm-up Round; the second is the
Challenge round. In the warm-up round, the user is asked a total of three simple questions and
they must be able to answer at least two of them correctly to enter the next round. If the user is
not capable of doing that, he is not permitted to proceed further.

In the second and more interesting round of this quiz game, the user will be asked questions
continuously, and for each right answer given, they will earn $100,000!

The game ends when the user’s cash prize piles up to $1 million. For each question asked, there
are 4 options, namely A, B, C and D. There are no negative markings, so the user’s accumulated
cash money won’t be deducted for wrong answers to the questions.

I have divided this mini project into many functions, and listed below are some of those which
may help you understand the project better.

edit_score() – adds the current cash prize won to the previous one upon giving the right answer
to a question

help() – help menu with game summary and rules

reset_score() – to reset the highest score/cash prize to default

show_record() – shows the highest cash prize won by a particular user

show_score() – to view the highest score

#include<stdio.h>

Page | 2
#include<string.h>

#include<stdlib.h>

#include<conio.h>

#include<windows.h>

struct dat//for date(month and day


{
int d,m;//d=day,m=month
};
int clscanf();//check class (1-12)
struct student
{
struct dat dt;
float f,fine,tot,adv,due;//f=fee
char n[50];
int r,c;//roll and class
} stud,s;
struct teacher
{
struct dat dt;
char n[50];
float sal,adv,tot;
int id,no;
} tech,t;
int chkdat(int,int);// for checking date
void addrec(int);//for adding records
void modrec(int);//for modifying records
void searchrec(int);//for searching records
void delrec(int);//for deleting records
void salary(int);//for the calculation of salary of teacher and staff
FILE *fs,*ft;//file declaration
Page | 3
int mm,dd;//mm=month, dd=day
void ext();//for exiting
void main(void)
{
int i,j,k;
for(i=0; i<80; i++)
{
printf("\xdb");
}
printf("\n");
for(i=0; i<80; i++)
{
printf("\xdb");
}
system("color 9a");
printf(" \t_______________________________________________________\n");
printf("\t| |\n");
printf("\t|**WELCOME TO C PROGRAM SCHOOL BILLING SYSTEM PROJECT|**\n");
printf("\n\t| |\n");
printf("\t ______________________________________________________\n");
printf("\t| DEVELOPED BY CODE WITH C TEAM |\n");
printf(" \t________________________________________________________\n");
printf("\t| ***************************************** |\n");
printf("\t| ***************************************** |\n");
printf(" \t_______________________________________________________\n");
printf("\n\tPLEASE ENTER ANY KEY TO CONTINUE");
for(i=0; i<5; i++)
{
printf(".");

Page | 4
Sleep(500);//after printing one . another comes after 0.5 seconds
}
getch();
system("cls");//clears the screen
printf("\n");
for(i=0; i<80; i++)
{
printf("\xdb");
}
system("color 6b");
printf("\n\n\t** WELCOME TO C PROGRAM SCHOOL BILLING SYSTEM PROJECT
**\n\n\n");
for(i=0; i<80; i++)
{
printf("\xdb");
}
printf("\nPLEASE ENTER ANY KEY TO START\n");
for(i=0; i<5; i++)
{
printf(".");
Sleep(500);
}
fflush(stdin);
getch();
system("cls");
system("color 0f");//1st is for back ground color and second is for text color
printf("\n\t\tPLEASE ENTER CURRENT DATE\nmm dd\n ");
scanf("%d%d",&mm,&dd);
mm=chkdat(mm,dd);
start();

Page | 5
}
void start()
{
int i,j;//j is for selection of account type
system("cls");
printf("\n\t\tPLEASE ENTER ACCOUNT TYPE");
printf("\n\t\t1:: Student");
printf("\n\t\t2:: Teachers and Staffs");
printf("\n\t\t3:: Exit");
printf("\n\t\tAccount type choice ");
fflush(stdin);
scanf("%d",&j);
switch (j)
{
case 3:
ext();
case 1:
{
system("cls");
printf("\n\t\tPLEASE ENTER THE CHOICE");
printf("\n\t\t1:: Add record");
printf("\n\t\t2:: Search record");
printf("\n\t\t3:: Modify record");
printf("\n\t\t4:: Delete record");
printf("\n\t\t5:: Calculate fee");
printf("\n\t\t6:: Exit");
printf("\n\n Enter choice ");
fflush(stdin);
scanf("%d",&i);
switch (i)

Page | 6
{
case 1:
addrec(j);//function call
start();//function call
case 2:
searchrec(j);
start();
case 3:
modrec(j);
start();
case 4:
delrec(j);
start();
case 5:
fee(mm);
start();
case 6:
ext();
default :
{
printf("\n\n\tInvalid entry!!");
printf("\n\nTo Account Type\n\n\t");
system("pause");
start();
}
}
}
case 2:
{

Page | 7
system("cls");
printf("\n\t\tPLEASE ENTER THE CHOICE");
printf("\n\t\t1:: Add record");
printf("\n\t\t2:: Search record");
printf("\n\t\t3:: Modify record");
printf("\n\t\t4:: Delete record");
printf("\n\t\t5:: Calculate Salary");
printf("\n\t\t6:: Exit");
printf("\n\n Enter choice ");
fflush(stdin);
scanf("%d",&i);
switch (i)
{
case 1:
addrec(j);
start();
case 2:
searchrec(j);
start();
case 3:
modrec(j);
start();
case 4:
delrec(j);
case 5:
salary(mm);
start();
case 6:
ext();
default :

Page | 8
{
printf("\n\n\tInvalid entry!!");
printf("\n\nTo Account Type\n\n\t");
system("pause");
start();
}

}
}
default :
{
printf("\n\n\tInvalid entry!!");
printf("\n\nTo Account Type\n\n\t");
system("pause");
start();
}
}
}

void addrec(int j)
{
int dif,cdat,ddat,month=0;//cdat=month till which fee is cleared
float ff;//used in calculatin of fee of different class
char c='y';
system("cls");

printf("\n\t******************************************************************");

printf("\n\t *************************** ");

Page | 9
printf("\n\t********************* ADD RECORD *******************");

printf("\n\t *************************** ");

printf("\n\t******************************************************************");
if (j==1)
{
while(c=='y'||c=='Y')
{
int a=1;
printf("\n\nEnter the name of student: ");
fflush(stdin);
scanf("%[^\n]",stud.n);
printf("\nEnter the class: ");
fflush(stdin);
stud.c=clscanf();
printf("\nEnter the Roll No.:");
fflush(stdin);
scanf("%2d",&stud.r);
printf("\nEnter month and day till which fee is paid:");
fflush(stdin);
scanf("%2d%2d",&cdat,&ddat);
cdat=chkdat(cdat,ddat);
stud.dt.m=cdat;
ff=stud.c/10.0;
stud.f=1000*(1+ff);//fee of different classes
dif=mm-stud.dt.m;//months of fee left to be paid
stud.fine=(dif*stud.f)*1/100;
stud.due=(dif)*stud.f;//fees left to be paid

Page | 10
if(dif==1)
{
stud.tot=stud.f;
stud.fine=0;
}
else
{
stud.tot=stud.fine+stud.due;
}//for calculation of total fee
fs=fopen("student","ab+");//opening a binary file in apend mode
fwrite(&stud,sizeof(stud),1,fs);
fclose(fs);
printf("\n\nDo you want to continue with the process(press y or Y");
fflush(stdin);
c=getch();
}
getch();
}
if (j==2)
{
while(c=='y'||c=='Y')
{
int a=1;
printf("\n\nEnter name of teacher/staff:" );
fflush(stdin);
scanf("%[^\n]",tech.n);
printf("\nEnter teacher/staff id: ");
fflush(stdin);
scanf("%d",&tech.id);
printf("\nEnter number of class/shift per month:: ");

Page | 11
scanf("%d",&tech.no);
fflush(stdin);
printf("\nEnter month and day till which salary is paid::");
scanf("%d %d",&tech.dt.m,&tech.dt.d);
cdat=chkdat(cdat,ddat);
tech.dt.m=cdat;
tech.sal=tech.no*500;
tech.adv=(tech.dt.m-mm-1)*tech.sal;
if (tech.adv<0) tech.adv=0;
tech.tot=tech.sal;
ft=fopen("teacher","ab+");
fwrite(&tech,sizeof(tech),1,ft);
fclose(ft);
printf("\n\nDo you want to continue with the process(press y or Y");
fflush(stdin);
c=getch();
}
fflush(stdin);
printf("\n\n");
system("pause");
}
}

void searchrec(int j)
{
char name[50],namet[50];
int a=1,choice;
char c='y';
if (j==1)
{

Page | 12
while(c=='y'||c=='Y')
{
int a=1;
system("cls");

printf("\n\t******************************************************************");

printf("\n\t *************************** ");

printf("\n\t********************* SEARCH RECORD *******************");

printf("\n\t *************************** ");

printf("\n\t******************************************************************");
printf("\n\n\t\tPLEASE CHOOSE SEARCH TYPE::");
printf("\n\n\t\t1::Search by name::");
printf("\n\n\t\t2::Search by class::");
printf("\n\n\t\t3::Search by rollno::");
printf("\n\n\t\t4::Exit");
printf("\n\n\t\t::Enter your choice:: ");
fflush(stdin);
scanf("%d",&choice);
if (choice==1)
{
#include<stdio.h>
#include<conio.h>
#include<ctype.h>
#include<stdlib.h>
#include<string.h>
void show_record();

Page | 13
void reset_score();
void help();
void edit_score(float , char []);
int main()
{
int countr,r,r1,count,i,n;
float score;
char choice;
char playername[20];
mainhome:
system("cls");
printf("\t\t\tC PROGRAM QUIZ GAME\n");
printf("\n\t\t________________________________________");

printf("\n\t\t\t WELCOME ");


printf("\n\t\t\t to ");
printf("\n\t\t\t THE GAME ");
printf("\n\t\t________________________________________");
printf("\n\t\t________________________________________");
printf("\n\t\t BECOME A MILLIONAIRE!!!!!!!!!!! ") ;
printf("\n\t\t________________________________________");
printf("\n\t\t________________________________________");
printf("\n\t\t > Press S to start the game");
printf("\n\t\t > Press V to view the highest score ");
printf("\n\t\t > Press R to reset score");
printf("\n\t\t > press H for help ");
printf("\n\t\t > press Q to quit ");
printf("\n\t\t________________________________________\n\n");
choice=toupper(getch());
if (choice=='V')

Page | 14
{
show_record();
goto mainhome;
}
else if (choice=='H')
{
help();getch();
goto mainhome;
}
else if (choice=='R')
{reset_score();
getch();
goto mainhome;}
else if (choice=='Q')
exit(1);
else if(choice=='S')
{
system("cls");

printf("\n\n\n\n\n\n\n\n\n\n\t\t\tResister your name:");


gets(playername);

system("cls");
printf("\n ------------------ Welcome %s to C Program Quiz Game --------------------------
",playername);
printf("\n\n Here are some tips you might wanna know before playing:");
printf("\n -------------------------------------------------------------------------");
printf("\n >> There are 2 rounds in this Quiz Game,WARMUP ROUND & CHALLANGE
ROUND");
printf("\n >> In warmup round you will be asked a total of 3 questions to test your");
printf("\n general knowledge. You are eligible to play the game if you give atleast 2");

Page | 15
printf("\n right answers, otherwise you can't proceed further to the Challenge Round.");
printf("\n >> Your game starts with CHALLANGE ROUND. In this round you will be asked
a");
printf("\n total of 10 questions. Each right answer will be awarded $100,000!");
printf("\n By this way you can win upto ONE MILLION cash prize!!!!!..........");
printf("\n >> You will be given 4 options and you have to press A, B ,C or D for the");
printf("\n right option.");
printf("\n >> You will be asked questions continuously, till right answers are given");
printf("\n >> No negative marking for wrong answers!");
printf("\n\n\t!!!!!!!!!!!!! ALL THE BEST !!!!!!!!!!!!!");
printf("\n\n\n Press Y to start the game!\n");
printf("\n Press any other key to return to the main menu!");
if (toupper(getch())=='Y')
{
goto home;
}
else
{
goto mainhome;
system("cls");
}

home:
system("cls");
count=0;
for(i=1;i<=3;i++)
{
system("cls");
r1=i;

Page | 16
switch(r1)
{
case 1:
printf("\n\nWhich of the following is a Palindrome number?");
printf("\n\nA.42042\t\tB.101010\n\nC.23232\t\tD.01234");
if (toupper(getch())=='C')
{
printf("\n\nCorrect!!!");count++;
getch();
break;
}
else
{
printf("\n\nWrong!!! The correct answer is C.23232");
getch();
break;
}

case 2:
printf("\n\n\nThe country with the highest environmental performance index
is...");
printf("\n\nA.France\t\tB.Denmark\n\nC.Switzerland\t\tD.Finland");
if (toupper(getch())=='C')
{printf("\n\nCorrect!!!");count++;
getch();
break;}
else
{printf("\n\nWrong!!! The correct answer is C.Switzerland");
getch();

Page | 17
break;}

case 3:
printf("\n\n\nWhich animal laughs like human being?");
printf("\n\nA.Polar Bear\t\tB.Hyena\n\nC.Donkey\t\tD.Chimpanzee");
if (toupper(getch())=='B')
{printf("\n\nCorrect!!!");count++;
getch();
break;}
else
{printf("\n\nWrong!!! The correct answer is B.Hyena");
getch();
break;}

case 4:
printf("\n\n\nWho was awarded the youngest player award in Fifa World Cup
2006?");
printf("\n\nA.Wayne Rooney\t\tB.Lucas Podolski\n\nC.Lionel
Messi\t\tD.Christiano Ronaldo");
if (toupper(getch())=='B')
{printf("\n\nCorrect!!!");count++;
getch();
break;}
else
{printf("\n\nWrong!!! The correct answer is B.Lucas Podolski");
getch();
break;}

case 5:
printf("\n\n\nWhich is the third highest mountain in the world?");
printf("\n\nA.Mt. K2\t\tB.Mt. Kanchanjungha\n\nC.Mt. Makalu\t\tD.Mt. Kilimanjaro");

Page | 18
if (toupper(getch())=='B')
{printf("\n\nCorrect!!!");count++;
getch();
break;}
else
{printf("\n\nWrong!!! The correct answer is B.Mt. Kanchanjungha");
getch();
break;}

case 6:
printf("\n\n\nWhat is the group of frogs known as?");
printf("\n\nA.A traffic\t\tB.A toddler\n\nC.A police\t\tD.An Army");
if (toupper(getch())=='D' )
{printf("\n\nCorrect!!!");count++;
getch();
break;}
else
{printf("\n\nWrong!!! The correct answer is D.An Army");
getch();
break;}}
}

if(count>=2)
{goto test;}
else
{
system("cls");
printf("\n\nSORRY YOU ARE NOT ELIGIBLE TO PLAY THIS GAME, BETTER
LUCK NEXT TIME");
getch();

Page | 19
goto mainhome;
}
test:
system("cls");
printf("\n\n\t*** CONGRATULATION %s you are eligible to play the Game
***",playername);
printf("\n\n\n\n\t!Press any key to Start the Game!");
if(toupper(getch())=='p')
{goto game;}
game:
countr=0;
for(i=1;i<=10;i++)
{system("cls");
r=i;

switch(r)
{
case 1:
printf("\n\nWhat is the National Game of England?");
printf("\n\nA.Football\t\tB.Basketball\n\nC.Cricket\t\tD.Baseball");
if (toupper(getch())=='C')
{printf("\n\nCorrect!!!");countr++;getch();
break;getch();}
else
{printf("\n\nWrong!!! The correct answer is C.Cricket");getch();
goto score;
break;}

case 2:
printf("\n\n\nStudy of Earthquake is called............,");

Page | 20
printf("\n\nA.Seismology\t\tB.Cosmology\n\nC.Orology\t\tD.Etimology");
if (toupper(getch())=='A')
{printf("\n\nCorrect!!!");countr++;getch();
break;}
else
{printf("\n\nWrong!!! The correct answer is A.Seismology");getch();
goto score;
break;
}

case 3:
printf("\n\n\nAmong the top 10 highest peaks in the world, how many lie in
Nepal? ");
printf("\n\nA.6\t\tB.7\n\nC.8\t\tD.9");
if (toupper(getch())=='C')
{printf("\n\nCorrect!!!");countr++;getch();
break;}
else
{printf("\n\nWrong!!! The correct answer is C.8");getch();
goto score;
break;}

case 4:
printf("\n\n\nThe Laws of Electromagnetic Induction were given by?");
printf("\n\nA.Faraday\t\tB.Tesla\n\nC.Maxwell\t\tD.Coulomb");
if (toupper(getch())=='A')
{printf("\n\nCorrect!!!");countr++;getch();
break;}
else
{

Page | 21
printf("\n\nWrong!!! The correct answer is A.Faraday");getch();
goto score;
break;
}

case 5:
printf("\n\n\nIn what unit is electric power measured?");
printf("\n\nA.Coulomb\t\tB.Watt\n\nC.Power\t\tD.Units");
if (toupper(getch())=='B')
{printf("\n\nCorrect!!!");countr++;getch(); break;}
else
{
printf("\n\nWrong!!! The correct answer is B.Power");
getch();
goto score;
break;
}

case 6:
printf("\n\n\nWhich element is found in Vitamin B12?");
printf("\n\nA.Zinc\t\tB.Cobalt\n\nC.Calcium\t\tD.Iron");
if (toupper(getch())=='B' )
{printf("\n\nCorrect!!!");countr++;getch();
break;}
else
{printf("\n\nWrong!!! The correct answer is B.Cobalt");goto score;
getch();
break;}

case 7:

Page | 22
printf("\n\n\nWhat is the National Name of Japan?");
printf("\n\nA.Polska\t\tB.Hellas\n\nC.Drukyul\t\tD.Nippon");
if (toupper(getch())=='D')
{printf("\n\nCorrect!!!");countr++;getch();
break;}
else
{printf("\n\nWrong!!! The correct answer is D.Nippon");getch();
goto score;
break;}

case 8:
printf("\n\n\nHow many times a piece of paper can be folded at the most?");
printf("\n\nA.6\t\tB.7\n\nC.8\t\tD.Depends on the size of paper");
if (toupper(getch())=='B')
{printf("\n\nCorrect!!!");countr++;getch(); break;}
else
{printf("\n\nWrong!!! The correct answer is B.7");getch();
goto score;
break;}

case 9:
printf("\n\n\nWhat is the capital of Denmark?");
printf("\n\nA.Copenhagen\t\tB.Helsinki\n\nC.Ajax\t\tD.Galatasaray");
if (toupper(getch())=='A')
{printf("\n\nCorrect!!!");countr++; getch();
break;}
else
{printf("\n\nWrong!!! The correct answer is A.Copenhagen");getch();
goto score;
break;}

Page | 23
case 10:
printf("\n\n\nWhich is the longest River in the world?");
printf("\n\nA.Nile\t\tB.Koshi\n\nC.Ganga\t\tD.Amazon");
if (toupper(getch())=='A')
{printf("\n\nCorrect!!!");countr++;getch(); break;}
else
{printf("\n\nWrong!!! The correct answer is A.Nile");getch();break;goto
score;}

case 11:
printf("\n\n\nWhat is the color of the Black Box in aeroplanes?");
printf("\n\nA.White\t\tB.Black\n\nC.Orange\t\tD.Red");
if (toupper(getch())=='C')
{printf("\n\nCorrect!!!");countr++;getch();
break;}
else
{printf("\n\nWrong!!! The correct answer is C.Orange");getch();
break;goto score;}

case 12:
printf("\n\n\nWhich city is known at 'The City of Seven Hills'?");
printf("\n\nA.Rome\t\tB.Vactican City\n\nC.Madrid\t\tD.Berlin");
if (toupper(getch())=='A')
{printf("\n\nCorrect!!!");countr++;getch();
break;}
else
{printf("\n\nWrong!!! The correct answer is A.Rome");getch();
break;goto score;}

Page | 24
case 13:
printf("\n\n\nName the country where there no mosquitoes are found?");
printf("\n\nA.Japan\t\tB.Italy\n\nC.Argentina\t\tD.France");
if (toupper(getch())=='D')
{printf("\n\nCorrect!!!");countr++;getch();
break;}
else
{printf("\n\nWrong!!! The correct answer is D.France");getch();
break;goto score;}

case 14:
printf("\n\n\nWho is the author of 'Pulpasa Cafe'?");
printf("\n\nA.Narayan Wagle\t\tB.Lal Gopal Subedi\n\nC.B.P.
Koirala\t\tD.Khagendra Sangraula");
if (toupper(getch())=='A')
{printf("\n\nCorrect!!!");countr++;getch();
break;}
else
{printf("\n\nWrong!!! The correct answer is A.Narayan Wagle");getch();
break;goto score;}

case 15:
printf("\n\n\nWhich Blood Group is known as the Universal Recipient?");
printf("\n\nA.A\t\tB.AB\n\nC.B\t\tD.O");
if (toupper(getch())=='B')
{printf("\n\nCorrect!!!");countr++;getch();
break;}
else
{printf("\n\nWrong!!! The correct answer is B.AB");getch();
goto score;

Page | 25
break;}

case 16:
printf("\n\n\nWhat is the unit of measurement of distance between Stars?");
printf("\n\nA.Light Year\t\tB.Coulomb\n\nC.Nautical Mile\t\tD.Kilometer");
if (toupper(getch())=='A')
{printf("\n\nCorrect!!!");countr++; getch();
break;
}
else
{printf("\n\nWrong!!! The correct answer is A.Light Year");getch();
goto score;
break;}

case 17:
printf("\n\n\nThe country famous for Samba Dance is........");
printf("\n\nA.Brazil\t\tB.Venezuela\n\nC.Nigeria\t\tD.Bolivia");
if (toupper(getch())=='A')
{printf("\n\nCorrect!!!");countr++; getch();
break;}
else
{printf("\n\nWrong!!! The correct answer is A.Brazil");getch();goto score;
break;}

case 18:
printf("\n\n\nWind speed is measure by__________?");
printf("\n\nA.Lysimeter\t\tB.Air vane\n\nC.Hydrometer\t\tD.Anemometer\n\n");
if (toupper(getch())=='D')
{printf("\n\nCorrect!!!");countr++; getch();

Page | 26
break;}
else
{printf("\n\nWrong!!! The correct answer is D.Anemometer");getch();goto
score;
break;}

case 19:
printf("\n\n\nWhich city in the world is popularly known as The City of
Temple?");
printf("\n\nA.Delhi\tB.Bhaktapur\n\nC.Kathmandu\tD.Agra\n\n");
if (toupper(getch())=='C')
{printf("\n\nCorrect!!!");countr++; getch();
break;}
else
{printf("\n\nWrong!!! The correct answer is C.Kathmandu");getch();goto
score;
break;}

case 20:
printf("\n\n\nWhich hardware was used in the First Generation Computer?");
printf("\n\nA.Transistor\t\tB.Valves\n\nC.I.C\t\tD.S.S.I");
if (toupper(getch())=='B')
{printf("\n\nCorrect!!!");countr++; getch();
break;}
else
{printf("\n\nWrong!!! The correct answer is B.Valves");getch();goto score;
break;}

case 21:
printf("\n\n\nOzone plate is being destroyed regularly because of____ ?");
printf("\n\nA.L.P.G\t\tB.Nitrogen\n\nC.Methane\t\tD. C.F.C");

Page | 27
if (toupper(getch())=='D')
{printf("\n\nCorrect!!!");countr++; getch();
break;}
else
{printf("\n\nWrong!!! The correct answer is D. C.F.C");getch();goto score;
break;}

case 22:
printf("\n\n\nWho won the Women's Australian Open Tennis in 2007?");
printf("\n\nA.Martina Hingis\t\tB.Maria Sarapova\n\nC.Kim Clijster\t\tD.Serena
Williams");
if (toupper(getch())=='D')
{printf("\n\nCorrect!!!");countr++; getch();
break;}
else
{printf("\n\nWrong!!! The correct answer is D.Serena
Williams");getch();goto score;
break;}

case 23:
printf("\n\n\nWhich film was awarded the Best Motion Picture at Oscar in
2010?");
printf("\n\nA.The Secret in their Eyes\t\tB.Shutter Island\n\nC.The King's
Speech\t\tD.The Reader");
if (toupper(getch())=='C')
{printf("\n\nCorrect!!!");countr++; getch();
break;}
else
{printf("\n\nWrong!!! The correct answer is C.The King's
Speech");getch();goto score;
break;}}}
score:

Page | 28
system("cls");
score=(float)countr*100000;
if(score>0.00 && score<1000000)
{
printf("\n\n\t\t**************** CONGRATULATION *****************");
printf("\n\t You won $%.2f",score);goto go;}

else if(score==1000000.00)
{
printf("\n\n\n \t\t**************** CONGRATULATION ****************");
printf("\n\t\t\t\t YOU ARE A MILLIONAIRE!!!!!!!!!");
printf("\n\t\t You won $%.2f",score);
printf("\t\t Thank You!!");
}
else
{
printf("\n\n\t******** SORRY YOU DIDN'T WIN ANY CASH ********");
printf("\n\t\t Thanks for your participation");
printf("\n\t\t TRY AGAIN");goto go;}

go:
puts("\n\n Press Y if you want to play next game");
puts(" Press any key if you want to go main menu");
if (toupper(getch())=='Y')
goto home;
else
{
edit_score(score,playername);
goto mainhome;}}}

Page | 29
void show_record()
{system("cls");
char name[20];
float scr;
FILE *f;
f=fopen("score.txt","r");
fscanf(f,"%s%f",&name,&scr);
printf("\n\n\t\t************************************************************
*");
printf("\n\n\t\t %s has secured the Highest Score %0.2f",name,scr);
printf("\n\n\t\t************************************************************
*");
fclose(f);
getch();}

void reset_score()
{system("cls");
float sc;
char nm[20];
FILE *f;
f=fopen("score.txt","r+");
fscanf(f,"%s%f",&nm,&sc);
sc=0;
fprintf(f,"%s,%.2f",nm,sc);
fclose(f);}

void help()
{system("cls");
printf("\n\n HELP");
printf("\n -------------------------------------------------------------------------");
printf("\n ......................... C program Quiz Game...........");

Page | 30
printf("\n >> There are two rounds in the game, WARMUP ROUND & CHALLANGE
ROUND");
printf("\n >> In warmup round you will be asked a total of 3 questions to test your general");
printf("\n knowledge. You will be eligible to play the game if you can give atleast 2");
printf("\n right answers otherwise you can't play the Game...........");
printf("\n >> Your game starts with the CHALLANGE ROUND. In this round you will be
asked");
printf("\n total 10 questions each right answer will be awarded $100,000.");
printf("\n By this way you can win upto ONE MILLION cash prize in USD...............");
printf("\n >> You will be given 4 options and you have to press A, B ,C or D for the");
printf("\n right option");
printf("\n >> You will be asked questions continuously if you keep giving the right answers.");
printf("\n >> No negative marking for wrong answers");

printf("\n\n\t*********************BEST OF
LUCK*********************************");
printf("\n\n\t*****C PROGRAM QUIZ GAME is developed by CODE WITH C
TEAM********");}

void edit_score(float score, char plnm[20])


{system("cls");
float sc;
char nm[20];
FILE *f;
f=fopen("score.txt","r");
fscanf(f,"%s%f",&nm,&sc);
if (score>=sc)
{ sc=score;
fclose(f);
f=fopen("score.txt","w");
fprintf(f,"%s\n%.2f",plnm,sc);
fclose(f);}} a=1;
Page | 31
printf("\n\nEnter name of student to search: ");
fflush(stdin);
scanf("%[^\n]",name);
fs=fopen("student","rb");
while(fread(&stud,sizeof(stud),1,fs)==1)
{
if (strcmpi(name,stud.n)==0)
{
a=0;
printf("\nname = %s",stud.n);
printf("\nclass = %d",stud.c);
printf("\nroll no = %d",stud.r);
printf("\nmonthy fee =%.2f",stud.f);
printf("\nlast fee paid in month =%2d",stud.dt.m);
printf("\n due=%.2f",stud.due);
printf("\n fine=%.2f",stud.fine);
printf("\n total=%.2f\n\n",stud.tot);
}
}
if (a==1)
printf("\n\nRECORD NOT FOUND");
printf("\n\n");
system("pause");
fflush(stdin);
fclose(fs);
}
else if (choice==2)
{
int cl;
a=1;

Page | 32
printf("\n\nEnter class of student to search: ");
fflush(stdin);
cl=clscanf();
fs=fopen("student","rb");
while(fread(&stud,sizeof(stud),1,fs)==1)
{
if (stud.c==cl)
{
a=0;
printf("\nname = %s",stud.n);
printf("\nclass = %d",stud.c);
printf("\nroll no = %d",stud.r);
printf("\nmonthy fee =%.2f",stud.f);
printf("\nlast fee paid in month =%2d",stud.dt.m);
printf("\n due=%.2f",stud.due);
printf("\n fine=%.2f",stud.fine);
printf("\n total=%.2f",stud.tot);
}
}
if (a==1)
printf("\n\nRECORD NOT FOUND");
printf("\n\n");
system("pause");
fflush(stdin);
fclose(fs);
}
else if (choice==3)
{
int rll;
a=1;

Page | 33
printf("\n\nEnter roll of student to search: ");
fflush(stdin);
rll=clscanf();
fs=fopen("student","rb");
while(fread(&stud,sizeof(stud),1,fs)==1)
{
if (strcmpi(name,stud.n)==0)
{
a=0;
printf("\nname = %s",stud.n);
printf("\nclass = %d",stud.c);
printf("\nroll no = %d",stud.r);
printf("\nmonthy fee =%.2f",stud.f);
printf("\nlast fee paid in month =%2d",stud.dt.m);
printf("\n due=%.2f",stud.due);
printf("\n fine=%.2f",stud.fine);
printf("\n total=%.2f",stud.tot);
}
}
if (a==1)
printf("\n\nRECORD NOT FOUND");
printf("\n\n");
system("pause");
fflush(stdin);
fclose(fs);
}
else if(choice==4)
{
ext();
}

Page | 34
else
{
printf("\n\n\n\t\tINVALID ENTRY!!!!\n\n\t\t");
system("pause");
searchrec(1);
}
printf("\n\nDo you want to continue with the process(press y or Y");
fflush(stdin);
c=getch();
}
getch();
}
if (j==2)
{
while(c=='y'||c=='Y')
{
int a=1;
printf("\n\nname of teacher/staff to search: ");
fflush(stdin);
scanf("%[^\n]",namet);
ft=fopen("teacher","rb");
while(fread(&tech,sizeof(tech),1,ft)==1)
{
if (strcmp(namet,tech.n)==0)
{
a=0;
printf("\nname = %s",tech.n);
printf("\nteacher/staff id = %d",tech.id);
printf("\nmonth till when salary is paid =%d",tech.dt.m);
printf("\nmonthy salary = %.2f",tech.sal);

Page | 35
printf("\nadvance paid = %.2f",tech.adv);
}
}
if (a==1)
printf("\n\nRECORD NOT FOUND");
printf("\n\n");
system("pause");
fflush(stdin);
fclose(ft);
printf("\n\nDo you want to continue with the process(press y or Y");
fflush(stdin);
c=getch();
}
getch();
}

void modrec(int j)
{

char name[50];
int a=1,choice,cl,rolno;
char c='y';
if (j==1)
{
while(c=='y'||c=='Y')
{
system("cls");

Page | 36
printf("\n\t******************************************************************");

printf("\n\t *************************** ");

printf("\n\t********************* MODIFY RECORD *******************");

printf("\n\t *************************** ");

printf("\n\t******************************************************************");
printf("\n\n\t\tPLEASE CHOOSE MODIFY TYPE::");
printf("\n\n\t\t1::Modify by name::");
printf("\n\n\t\t2::Modify by name &class::");
printf("\n\n\t\t3::Modify by name,class & rollno::");
printf("\n\n\t\t4::Exit");
printf("\n\n\t\t::Enter your choice:: ");
fflush(stdin);
scanf("%d",&choice);
if (choice==1)
{
int a=0;
printf("\n\nenter name of student to modify: ");
fflush(stdin);
scanf("%[^\n]",name);
fs=fopen("student","rb+");
while(fread(&stud,sizeof(stud),1,fs)==1)
{
a=1;
if (strcmpi(name,stud.n)==0)
{

Page | 37
a=0;
printf("\nenter new name of student: ");
fflush(stdin);
scanf("%[^\n]",stud.n);
printf("\nenter new class of student: ");
fflush(stdin);
stud.c=clscanf();
printf("\nenter new roll of student: ");
fflush(stdin);
scanf("%d",&stud.r);
fseek(fs,-sizeof(stud),SEEK_CUR);
fwrite(&stud,sizeof(stud),1,fs);
fclose(fs);
}
}
if (a==1)
printf("\n\nRECORDS NOT FOUND");
else
printf("\n\nRECORDS SUCCESSFULLY MODIFIED");
printf("\n\n");
system("pause");
}
else if (choice==2)
{
int a=0;
printf("\n\nenter name of student to modify: ");
fflush(stdin);
scanf("%[^\n]",name);
printf("\n\nenter class of student to modify: ");
fflush(stdin);

Page | 38
cl=clscanf();
fs=fopen("student","rb+");
while(fread(&stud,sizeof(stud),1,fs)==1)
{
a=1;
if (strcmpi(name,stud.n)==0 && cl==stud.c)
{
a=0;
printf("\nenter new name of student: ");
fflush(stdin);
scanf("%[^\n]",stud.n);
printf("\nenter new class of student: ");
fflush(stdin);
stud.c=clscanf();
printf("\nenter new roll of student: ");
fflush(stdin);
scanf("%d",&stud.r);
fseek(fs,-sizeof(stud),SEEK_CUR);
fwrite(&stud,sizeof(stud),1,fs);
fclose(fs);
}
}
if (a==1)
printf("\n\nRECORDS NOT FOUND");
else
printf("\n\nRECORDS SUCCESSFULLY MODIFIED");
printf("\n\n");
system("pause");
}
else if (choice==3)

Page | 39
{
int a=0;
printf("\n\nenter name of student to modify: ");
fflush(stdin);
scanf("%[^\n]",name);
printf("\n\nenter class of student to modify: ");
fflush(stdin);
cl=clscanf();
printf("\n\nenter roll of student to modify: ");
fflush(stdin);
scanf("%d",&rolno);
fs=fopen("student","rb+");
while(fread(&stud,sizeof(stud),1,fs)==1)
{
a=1;
if (strcmpi(name,stud.n)==0 && cl==stud.c &&rolno==stud.r)
{
a=0;
printf("\nenter new name of student: ");
fflush(stdin);
scanf("%[^\n]",stud.n);
printf("\nenter new class of student: ");
fflush(stdin);
stud.c=clscanf();
printf("\nenter new roll of student: ");
fflush(stdin);
scanf("%d",&stud.r);
fseek(fs,-sizeof(stud),SEEK_CUR);
fwrite(&stud,sizeof(stud),1,fs);
fclose(fs);

Page | 40
}
}
if (a==1)
printf("\n\nRECORDS NOT FOUND");
else
printf("\n\nRECORDS SUCCESSFULLY MODIFIED");
printf("\n\n");
system("pause");
}
else if (choice==4) ext();
else
{
printf("\n\n\n\t\tINVALID ENTRY!!!!\n\n\t\t");
system("pause");
modrec(1);
}

printf("\n\nDo you want to continue with the process(press y or Y");


fflush(stdin);
c=getch();
}
getch();
}

if (j==2)
{
while(c=='y'||c=='Y')
{
int a=1;
printf("enter name of teacher to modify: ");

Page | 41
fflush(stdin);
scanf("%[^\n]",name);
ft=fopen("teacher","rb+");
while(fread(&tech,sizeof(tech),1,ft)==1)
{
if (strcmpi(name,tech.n)==0)
{
a=0;
printf("\nenter new name of teacher: ");
fflush(stdin);
scanf("%[^\n]",tech.n);
printf("\nenter new id of teacher: ");
fflush(stdin);
scanf("%d",&tech.id);
fseek(ft,-sizeof(tech),SEEK_CUR);
fwrite(&tech,sizeof(tech),1,ft);
fclose(ft);
}
}

if (a==1)
printf("\n\nRECORD NOT FOUND");
else
printf("\n\nRECORD SUCCESSFULLY MODIFIED");
printf("\n\n");
system("pause");
fflush(stdin);

printf("\n\nDo you want to continue with the process(press y or Y");


fflush(stdin);

Page | 42
c=getch();
}
getch();
}
}

void delrec(int j)
{
system("cls");

printf("\n\t******************************************************************");

printf("\n\t *************************** ");

printf("\n\t********************* DELETE RECORD *******************");

printf("\n\t *************************** ");

printf("\n\t******************************************************************");
FILE *temp,*t1;
int a=1;
char name[50],c='y';
if (j==1)
{
while(c=='y'||c=='Y')
{
int a=1;
printf("\n\nenter name of student to delete: ");
fflush(stdin);
scanf("%[^\n]",name);

Page | 43
fs=fopen("student","rb");
temp=fopen("tempfile","wb");//opening of temporary file for deleting process
while (fread(&stud,sizeof(stud),1,fs)==1)
{
if (strcmp(stud.n,name)==0)
{
a=0;
continue;
}
else
{
fwrite(&stud,sizeof(stud),1,temp);
}
}

if (a==1)
printf("\n\nRECORD NOT FOUND");
else
printf("\n\nRECORD SUCCESSFULLY DELETED");
printf("\n\n");
system("pause");
fflush(stdin);

fclose(fs);
fclose(temp);
system("del student");/*all data except the data to be
deleted in student were 1st moved to temp and data in student
was deleted*/
system("ren tempfile, student");//renaming temp to student
printf("\n\nDo you want to continue with the process(press y or Y");

Page | 44
fflush(stdin);
c=getch();
}
getch();
}

if (j==2)
{
a=1;
char namet[50];
while(c=='y'||c=='Y')
{
printf("\n\nEnter name of teacher to delete record: ");
fflush(stdin);
scanf("%[^\n]",namet);
ft=fopen("teacher","rb");
t1=fopen("tempfile1","wb");
while (fread(&tech,sizeof(tech),1,ft)==1)
{
if (strcmp(tech.n,namet)==0)
{
a=0;
continue;
}
else
{
fwrite(&tech,sizeof(tech),1,t1);
}
}

Page | 45
if (a==1)
printf("\n\nRECORD NOT FOUND");
else
printf("\n\nRECORD SUCCESSFULLY DELETED");
printf("\n\n");
system("pause");
fflush(stdin);

fclose(ft);
fclose(t1);
system("del teacher");
system("ren tempfile1, teacher");
printf("\n\nDo you want to continue with the process(press y or Y");
fflush(stdin);
c=getch();
}
getch();
}
}
void salary(int mm)
{
system("cls");

printf("\n\t******************************************************************");

printf("\n\t *************************** ");

printf("\n\t********************* SALARY *******************");

printf("\n\t *************************** ");

Page | 46
printf("\n\t******************************************************************");
FILE *f,*t;
int a=1,day;
char name[50],c='y';
int month,dif,id;
while(c=='y'||c=='Y')
{
int a=1;
fflush(stdin);
printf("\n\nEnter name:: ");
scanf("%[^\n]",name);
printf("\n\nEnter ID:: ");
scanf("%d",&id);
f=fopen("teacher","rb+");
t=fopen("te","wb+");
while(fread(&tech,sizeof(tech),1,f)==1)//file opened
{
if(strcmp(tech.n,name)==0 )//name entered is compared to the existing name in file
{
float lsal;
a=0;
printf("\n\nEnter the month till which salary is to be paid:: ");
fflush(stdin);
scanf("%d",&month);
month=chkdat(month,day);
tech.adv=(month-mm-1)*tech.sal;
if (tech.adv<0) tech.adv=0;
lsal=mm-tech.dt.m;//months of salary left to be paid

Page | 47
if(lsal<0) lsal=0;
tech.tot=tech.adv+tech.sal*(1+lsal);
if(month==tech.dt.m) tech.tot=0;
printf("\nmonthy salary left to be paid:: %.2f",lsal);
printf("\ntotal :: %.2f",tech.tot);
printf("\nadvance :: %.2f",tech.adv);
tech.dt.m=month;
fwrite(&tech,sizeof(tech),1,t);
fclose(f);
fclose(t);

if (a==1)
printf("\n\nRECORD NOT FOUND");
printf("\n\n");
system("pause");
fflush(stdin);
system("del teacher");
system("ren te, teacher");
}
}
printf("\n\nDo you want to continue with the process(press y or Y");
fflush(stdin);
c=getch();
}
getch();
}

void fee(int mm)


{
system("cls");

Page | 48
printf("\n\t******************************************************************");

printf("\n\t *************************** ");

printf("\n\t********************* FEE *******************");

printf("\n\t *************************** ");

printf("\n\t******************************************************************");
FILE *f,*t;
int a=0;
char name[50],c='y';
int clas, roll,month,dif;
while(c=='y'||c=='Y')
{
int a=1,day=0;
fflush(stdin);
printf("\n\nEnter name:: ");
scanf("%[^\n]",name);
printf("\n\nEnter class:: ");
fflush(stdin);
clas=clscanf();
printf("\n\nEnter roll:: ");
fflush(stdin);
scanf("%d",&roll);
f=fopen("student","rb+");
t=fopen("te","wb");
while(fread(&stud,sizeof(stud),1,f)==1)
{

Page | 49
if(strcmp(stud.n,name)==0 && clas==stud.c && roll==stud.r)
{
a=0;
printf("\n\nEnter the month till which fee to be paid:: ");
fflush(stdin);
scanf("%d",&month);
month=chkdat(month,day);
dif=mm-stud.dt.m;
stud.fine=(dif*stud.f)*0.01;
stud.due=(dif)*stud.f;
if (stud.fine<0) stud.fine=0;
if (stud.due<0) stud.due=0;
if (stud.tot<0) stud.tot=0;
stud.tot=stud.fine+stud.due+stud.adv;
printf("\nfine :: %.2f",stud.fine);
printf("\ndue :: %.2f",stud.due);
printf("\ntotal :: %.2f",stud.tot);
printf("\nadvance :: %.2f",stud.adv);
stud.dt.m=month;
stud.tot=0;
stud.fine=0;
stud.due=0;
fwrite(&stud,sizeof(stud),1,t);
}
}
if (a==1)
printf("\n\nRECORD NOT FOUND");
printf("\n\n");
system("pause");
fflush(stdin);

Page | 50
fclose(f);
fclose(t);
system("del student");
system("ren te, student");
printf("\n\nDo you want to continue with the process(press y or Y");
fflush(stdin);
c=getch();
}
getch();
}
void ext()
{
int i;
system("color 0c");
printf("\n\n\t\t Thank you for using C Program School Billing System Project\n\n");
system("pause");
system("cls");
printf("\n\n\t\t\t Exiting\n\n");
for(i=1; i<=80; i++)
{
Sleep(50);
printf("*");
}
exit(0);
}

int chkdat(int mnt,int dnt)


{
int mon,day;

Page | 51
if (mnt>12 || mnt<1 || dnt<1 || dnt>32)
{
MessageBox(0,"Invalid Date!\nEnter Again","Error!",0);

fflush(stdin);
scanf("%d%d",&mon,&day);
mon=chkdat(mon,day);
}
else
return (mnt);
}
int clscanf()
{
int mnt,mon;
fflush(stdin);
scanf("%d",&mnt);
if (mnt>12 ||mnt<1)
{

MessageBox(0,"Invalid Class!\nEnter Class","Error!!",0);


fflush(stdin);
mon=clscanf();
}
else
return mnt;
}

Page | 52
Screenshots

Welcome Screen:

Correct Answer

Page | 53
Highest Score:

Page | 54

You might also like