0% found this document useful (0 votes)
6 views28 pages

Sujen C Project

Uploaded by

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

Sujen C Project

Uploaded by

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

"A college with difference…..

"

Biratnagar-10, Tintoliya

Ph. No.:- 021-470149, 460822

ESTD-2033

Class:- 12 Subject:- Computer Section:- Lebnitz

SUBMITTED BY:- SUBMITTED TO:-

NAME:-SUJEN SINGH SARDAR DEPARTMENT OF COMPUTER

ROLL NO.:- 1238

Signature
ACKNOWLEDGEMENT

I would like to express my gratitude towards my computer


teacher Mr. Abhay Karn sir as well as our principal sir Mr. Rajesh
karki who gave me an opportunity to do this wonderful
assignment. It helped me in learning new things and I
encountered so many things which I didn’t knew earlier.
Also, I would like to thank my parents and friends who
helped me a lot in completion of this project within deadline.

THANK YOU!
-Sujen Singh Sardar
Source Code:

#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <string.h>
#include <ctype.h>
void high_score(char p[], int score);
void rules();
int main()
{
char playername[20], choice, score = 0, option;
;
int selection, x[12]; // change
system("cls");
printf("\n\n\n\n\t\t\tEnter your first name:");
scanf("%s", playername);
homescreen:
system("cls");

printf("\n\n\n\t\t\t\tWELCOME TO THE QUIZ GAME");


printf("\n\t\t\t________________________________________");
printf("\n\n\n\t\t\tType 'S' to Begin the game.");
printf("\n\t\t\tType 'R' to Study the rules of the game.");
printf("\n\t\t\tType 'H' to Know your high score.");
printf("\n\t\t\tType 'E' to exit the game");
printf("\n\n\t\t\t________________________________________\n\n");
choice = toupper(getch());
if (choice == 'H')
{
high_score(playername, score);
goto homescreen;
}
else if (choice == 'R')
{
rules();
goto homescreen;
}
else if (choice == 'S')
{
score = 0;
quizlayout:

if (score == 120)
{
system("cls");
printf("\n\n\n\t\t\t\t!!!CONGRATULATIONS!!!");
printf("\n\t\t\t________________________________________");
printf("\n\n\t\t\t\tYOU COMPLETED THE GAME");
printf("\n\n\t\t\t\tYour Score is %d", score);
printf("\n\n\t\t\t________________________________________\n\n");
getch();
goto terminate;
}
system("cls");
printf("\n\n\n\t\t\t\tWELCOME TO THE QUIZ GAME");
printf("\n\t\t\t________________________________________");
printf("\n\n\n\t\t\t1\t2\t3\t4\t5\t6");
printf("\n\n\t\t\t7\t8\t9\t10\t11\t12");
printf("\n\n\t\t\t________________________________________\n\n");
printf("\n\n\t\t\tType the question number: ");
scanf("%d", &selection);

for (int i = 0; i < 12; i++) // change


{
if (x[i] == selection)
{
printf("\n\n\t\t\tInvalid option or the question is already selected!!");
getch();
goto quizlayout;
}
}
switch (selection)
{
case 1:

system("cls");
printf("\n\n\n\t\t\t\tWELCOME TO THE QUIZ GAME");
printf("\n\t\t\t________________________________________");
printf("\n\n\n\t\t\t1.Which country won 2022 FIFA World Cup?");

printf("\n\n\t\t\tA.France\t\t\tB.Argentina\n\n\t\t\tC.Denmark\t\t\tD.Croatia");

printf("\n\n\t\t\t________________________________________\n\n");
printf("\n\n\t\t\tType the option: ");
option = toupper(getch());

if (option == 'B')
{

printf("\n\t\t\tCorrect!!");

getch();
x[0] = selection;

score = score + 10;


goto quizlayout;
}
else if ((option == 'A') || (option == 'C') || (option == 'D'))
{
printf("\n\t\t\tWrong!!");
getch();
memset(x, 0, sizeof(int) * 12); // resets 'x' array to 0
high_score(playername, score);
goto homescreen;
}
else
{
printf("\n\t\t\tEnter a valid option!!");
}

getch();
goto quizlayout;
break;
case 2:

system("cls");
printf("\n\n\n\t\t\t\tWELCOME TO THE QUIZ GAME");
printf("\n\t\t\t________________________________________");
printf("\n\n\n\t\t\t2.Who was the first nepali to climb Mt. Everest?");
printf("\n\n\t\t\tA.Edmund Hillary\t\tB.Tenzing Norgay
Sherpa\n\n\t\t\tC.Mingma Sherpa\t\t\tD.Pasang Lhamu Sherpa");

printf("\n\n\t\t\t________________________________________\n\n");
printf("\n\n\t\t\tType the option: ");
option = toupper(getch());
if (option == 'B')
{
printf("\n\t\t\tCorrect!!");

getch();
x[1] = selection;
score = score + 10;

goto quizlayout;
}
else if ((option == 'A') || (option == 'C') || (option == 'D'))
{
printf("\n\t\t\tWrong!!");
getch();
memset(x, 0, sizeof(int) * 12);
high_score(playername, score);
goto homescreen;
}
else
{
printf("\n\t\t\tEnter a valid option!!");
}

getch();
goto quizlayout;
break;
case 3:

system("cls");
printf("\n\n\n\t\t\t\tWELCOME TO THE QUIZ GAME");
printf("\n\t\t\t________________________________________");
printf("\n\n\n\t\t\t3.Which is the smallest district of Nepal\n\t\t\tafter
local level division?");

printf("\n\n\t\t\tA.Baitadi\t\t\tB.Bajhang\n\n\t\t\tC.Bhaktapur\t\t\tD.Parbat");

printf("\n\n\t\t\t________________________________________\n\n");
printf("\n\n\t\t\tType the option: ");
option = toupper(getch());
if (option == 'C')
{
printf("\n\t\t\tCorrect!!");

getch();
x[2] = selection;
score = score + 10;

goto quizlayout;
}
else if ((option == 'A') || (option == 'B') || (option == 'D'))
{
printf("\n\t\t\tWrong!!");
getch();
memset(x, 0, sizeof(int) * 12);
high_score(playername, score);
goto homescreen;
}
else
{
printf("\n\t\t\tEnter a valid option!!");
}

getch();
goto quizlayout;
break;
case 4:

system("cls");
printf("\n\n\n\t\t\t\tWELCOME TO THE QUIZ GAME");
printf("\n\t\t\t________________________________________");
printf("\n\n\n\t\t\t4.What was the time of the 2072
earthquake\n\t\t\toccured in Nepal?");
printf("\n\n\t\t\tA.11:52 am\t\t\tB.11:37 am\n\n\t\t\tC.12:00
pm\t\t\tD.11:56 am");

printf("\n\n\t\t\t________________________________________\n\n");
printf("\n\n\t\t\tType the option: ");
option = toupper(getch());
if (option == 'D')
{
printf("\n\t\t\tCorrect!!");

getch();
x[3] = selection;
score = score + 10;

goto quizlayout;
}
else if ((option == 'A') || (option == 'C') || (option == 'B'))
{
printf("\n\t\t\tWrong!!");
getch();
memset(x, 0, sizeof(int) * 12);
high_score(playername, score);
goto homescreen;
}
else
{
printf("\n\t\t\tEnter a valid option!!");
}

getch();
goto quizlayout;
break;
case 5:

system("cls");
printf("\n\n\n\t\t\t\tWELCOME TO THE QUIZ GAME");
printf("\n\t\t\t________________________________________");
printf("\n\n\n\t\t\t5.What is called the blank sheet on the front\n\t\t\tand
back of the book?");
printf("\n\n\t\t\tA.Fly Leaf\t\t\tB.Endsheet\n\n\t\t\tC.Blank
Sheet\t\t\tD.Empty Sheet");

printf("\n\n\t\t\t________________________________________\n\n");
printf("\n\n\t\t\tType the option: ");
option = toupper(getch());
if (option == 'A')
{
printf("\n\t\t\tCorrect!!");

getch();
x[4] = selection;
score = score + 10;

goto quizlayout;
}
else if ((option == 'B') || (option == 'C') || (option == 'D'))
{
printf("\n\t\t\tWrong!!");
getch();
memset(x, 0, sizeof(int) * 12);
high_score(playername, score);
goto homescreen;
}
else
{
printf("\n\t\t\tEnter a valid option!!");
}

getch();
goto quizlayout;
break;
case 6:

system("cls");
printf("\n\n\n\t\t\t\tWELCOME TO THE QUIZ GAME");
printf("\n\t\t\t________________________________________");
printf("\n\n\n\t\t\t6.What is the national game of Nepal?");
printf("\n\n\n\t\t\tA.Kabaddi\t\t\tB.Dandi
biyo\n\n\t\t\tC.Volleyball\t\t\tD.Hockey");

printf("\n\n\t\t\t________________________________________\n\n");
printf("\n\n\t\t\tType the option: ");
option = toupper(getch());
if (option == 'C')
{
printf("\n\t\t\tCorrect!!");

getch();
x[5] = selection;
score = score + 10;

goto quizlayout;
}
else if ((option == 'A') || (option == 'B') || (option == 'D'))
{
printf("\n\t\t\tWrong!!");
getch();
memset(x, 0, sizeof(int) * 12);
high_score(playername, score);
goto homescreen;
}
else
{
printf("\n\t\t\tEnter a valid option!!");
}

getch();
goto quizlayout;
break;
case 7:

system("cls");
printf("\n\n\n\t\t\t\tWELCOME TO THE QUIZ GAME");
printf("\n\t\t\t________________________________________");
printf("\n\n\n\t\t\t7.In C, what is the correct hierarchy of\n\t\t\tarithmetic
operations?");
printf("\n\n\t\t\tA. * / + -\t\t\tB. / * + -\n\n\t\t\tC. + - * /\t\t\tD. - * + /");

printf("\n\n\t\t\t________________________________________\n\n");
printf("\n\n\t\t\tType the option: ");
option = toupper(getch());
if (option == 'B')
{
printf("\n\t\t\tCorrect!!");

getch();
x[6] = selection;
score = score + 10;

goto quizlayout;
}
else if ((option == 'A') || (option == 'C') || (option == 'D'))
{
printf("\n\t\t\tWrong!!");
getch();
memset(x, 0, sizeof(int) * 12);
high_score(playername, score);
goto homescreen;
}
else
{
printf("\n\t\t\tEnter a valid option!!");
}
getch();
goto quizlayout;
break;
case 8:

system("cls");
printf("\n\n\n\t\t\t\tWELCOME TO THE QUIZ GAME");
printf("\n\t\t\t________________________________________");
printf("\n\n\n\t\t\t8.What is the standard meridian of Nepal?");
printf("\n\n\t\t\tA. 85 Deg. 15' E\t\tB. 88 Deg. 15' E\n\n\t\t\tC. 80 Deg. 15'
E\t\tD. 86 Deg. 15' E");

printf("\n\n\t\t\t________________________________________\n\n");
printf("\n\n\t\t\tType the option: ");
option = toupper(getch());
if (option == 'D')
{
printf("\n\t\t\tCorrect!!");

getch();
x[7] = selection;
score = score + 10;

goto quizlayout;
}
else if ((option == 'A') || (option == 'C') || (option == 'B'))
{
printf("\n\t\t\tWrong!!");
getch();
memset(x, 0, sizeof(int) * 12);
high_score(playername, score);
goto homescreen;
}
else
{
printf("\n\t\t\tEnter a valid option!!");
}

getch();
goto quizlayout;
break;
case 9:

system("cls");
printf("\n\n\n\t\t\t\tWELCOME TO THE QUIZ GAME");
printf("\n\t\t\t________________________________________");
printf("\n\n\n\t\t\t9.In mountaineering, the region above 8000m\n\t\t\tis
referred as ");
printf("\n\n\t\t\tA.Lethal Zone\t\tB.Oxygen Depletion
Zone\n\n\t\t\tC.Death Zone\t\tD.Extreme Cold Zone");
printf("\n\n\t\t\t________________________________________\n\n");
printf("\n\n\t\t\tType the option: ");
option = toupper(getch());
if (option == 'C')
{
printf("\n\t\t\tCorrect!!");

getch();
x[8] = selection;
score = score + 10;

goto quizlayout;
}
else if ((option == 'A') || (option == 'B') || (option == 'B'))
{
printf("\n\t\t\tWrong!!");
getch();
memset(x, 0, sizeof(int) * 12);
high_score(playername, score);
goto homescreen;
}
else
{
printf("\n\t\t\tEnter a valid option!!");
}

getch();
goto quizlayout;
break;
case 10:

system("cls");
printf("\n\n\n\t\t\t\tWELCOME TO THE QUIZ GAME");
printf("\n\t\t\t________________________________________");
printf("\n\n\n\t\t\t10.When did Pres. Bidya D. Bhandari
dissolved\n\t\t\tHOR per advice of PM KP Sharma Oli?");
printf("\n\n\t\t\tA. Paush 5,2077 BS\t\tB. Paush 17,2077 BS\n\n\t\t\tC.
Magh 3,2077 BS\t\tD. Paush 7,2077 BS");

printf("\n\n\t\t\t________________________________________\n\n");
printf("\n\n\t\t\tType the option: ");
option = toupper(getch());
if (option == 'A')
{
printf("\n\t\t\tCorrect!!");

getch();
x[9] = selection;
score = score + 10;

goto quizlayout;
}
else if ((option == 'D') || (option == 'C') || (option == 'B'))
{
printf("\n\t\t\tWrong!!");
getch();
memset(x, 0, sizeof(int) * 12);
high_score(playername, score);
goto homescreen;
}
else
{
printf("\n\t\t\tEnter a valid option!!");
}

getch();
goto quizlayout;
break;
case 11:

system("cls");
printf("\n\n\n\t\t\t\tWELCOME TO THE QUIZ GAME");
printf("\n\t\t\t________________________________________");
printf("\n\n\n\t\t\t11.Which is the nation with the most borders\n\t\t\tin
the world?");
printf("\n\n\t\t\tA. Russia\t\t\tB. Brazil\n\n\t\t\tC. China\t\t\tD. Canada");

printf("\n\n\t\t\t________________________________________\n\n");
printf("\n\n\t\t\tType the option: ");
option = toupper(getch());
if (option == 'C')
{
printf("\n\t\t\tCorrect!!");

getch();
x[10] = selection;
score = score + 10;

goto quizlayout;
}
else if ((option == 'A') || (option == 'D') || (option == 'B'))
{
printf("\n\t\t\tWrong!!");
getch();
memset(x, 0, sizeof(int) * 12);
high_score(playername, score);
goto homescreen;
}
else
{
printf("\n\t\t\tEnter a valid option!!");
}

getch();
goto quizlayout;
break;
case 12:

system("cls");
printf("\n\n\n\t\t\t\tWELCOME TO THE QUIZ GAME");
printf("\n\t\t\t________________________________________");
printf("\n\n\n\t\t\t12.Name the country where mosquitoes aren't
found?");
printf("\n\n\t\t\tA. Argentina\t\t\tB. Japan\n\n\t\t\tC. France\t\t\tD.
Italy");

printf("\n\n\t\t\t________________________________________\n\n");
printf("\n\n\t\t\tType the option: ");
option = toupper(getch());
if (option == 'C')
{
printf("\n\t\t\tCorrect!!");
getch();
x[11] = selection;
score = score + 10;

goto quizlayout;
}
else if ((option == 'A') || (option == 'D') || (option == 'B'))
{
printf("\n\t\t\tWrong!!");
getch();
memset(x, 0, sizeof(int) * 12);
high_score(playername, score);
goto homescreen;
}
else
{
printf("\n\t\t\tEnter a valid option!!");
}

getch();
goto quizlayout;
break;
default:
printf("\n\t\t\tPlease enter a valid question no.!!");
getch();
goto quizlayout;
break;
break;
}
}
else if (choice == 'E')
{
terminate:
exit;
}
else
{
printf("\n\n\t\t\tPlease choose a valid operation");
}

return 0;
}
void high_score(char p[], int score)
{
FILE *fp;
system("cls");
fp = fopen("score.txt", "w");
fprintf(fp, "Playername:%s Score=%d", p, score);
fclose(fp);
fp = fopen("score.txt", "r");
while ((fscanf(fp, "Playername:%s Score=%d", p, &score)) != EOF)
{
printf("\n\n\n\t\t\tPlayername:%s\n\t\t\tHighscore=%d", p, score);
}

getch();
}

void rules()
{
system("cls");
printf("\n\n\n\t\t --RULES TO BE REMEMBERED--");
printf("\n\t\t\t________________________________________");
printf("\n\n\n\t\t\t1.There are total 12 questions each question");
printf("\n\t\t\tconsists of 10 points.");
printf("\n\n\t\t\t2.You will be given 4 options A,B,C,D. You have");
printf("\n\t\t\tto type the option of the following answer to");
printf("\n\t\t\tchoose your answer.");
printf("\n\n\t\t\t3.If you give correct answer you will proceed");
printf("\n\t\t\tto another question but in case of wrong answer");
printf("\n\t\t\tyou have to start the quiz from beginning.");
printf("\n\n\t\t\t________________________________________\n\n");
printf("\n\t\t\t\t BEST OF LUCK");
getch();
}

Output Screenshots:

You might also like