C Project : Quiz Game in hindi in c language c प्रोजेक्ट , क्विज गेम क्या है हिंदी में समझाइये , कैसे कार्य करता है

c प्रोजेक्ट , क्विज गेम क्या है हिंदी में समझाइये , कैसे कार्य करता है C Project : Quiz Game in hindi in c language :-
इस प्रोजेक्ट मे हम एक quiz game का प्रोग्राम बनायेगे |इस प्रोजेक्ट के लिए चार concept का ज्ञान होना चाहिए :
1. Switch statement
ये एक condition statement है जिसमे की अलग अलग case या executable block होते है |switch statement के अलावा goto statement को use भी किया गया है |
2. looping
इस प्रोग्रम मे looping (for loop) का use किया गया है |
3. function
इस प्रोग्रम मे function के concept को use किया गया है |ये प्रोग्रम्म 255 lines का है इसे तीन भाग यानि function मे डिवाइड किया है |
4. file management
इस प्रोग्राम मे किसी file मे data को save करना और write करने का subprogram है |इस प्रोग्राम मे तीन function है :
1.dispaly_record() :dispaly_record() का use file मे सेव data को देखने के लिए subprogram है |
2. save_score(float , char []) : save_score(float , char []) का use player द्वारा खेले गये game के score को file मे store करने का subprogram है |
3. main()
main () का use ये प्रोग्रम की हार्ट है |सभी quiz के question और लॉजिक इसी main() function मे store है |
इसमें तीन block होते है :-
Home : इस block मे प्लेयर के द्वारा कमांड्स को लिया जाता है
command 1: display view detail,game start  या quit game के लिए|
(i)अगर प्लेयर ,view detail का option choose करता है तब प्रोग्राम का control, function display_record पर चला जाता है |
(ii)अगर प्लेयर game start का option choose करता है तब प्लेयर से उसका नाम पुच कर game की general details बताई जाती |
(iii)अगर प्लेयर exit का option करता है तब , कंट्रोलर प्रोग्रम को terminate कर देता है |
command2 :ये block प्लेयर द्वारा start game option choose करने पर run होता है |
सबसे पहले प्लेयर से नाम पूछा जाता है |और प्लेयर द्वारा दिए गये input को string name[] मे store कर दिया जाता है |
बाद मे general detail बता कर , प्लेयर से game start करने का command मागा जाता है |अगर प्लेयर ‘Y ‘ सेलेक्ट कर देता है tab control ‘home 2 ‘ पर चला जाता है |अगर प्लेयर game start का option choose नहीं करता तब home screen फिर से run हो जाती है |
home 2 :
इसमें सभी question और answer का set होता है |
इसमें forloop को 10 बार बार चलाया जाता है |और i की value को switch मे पास्ड किया जाता है हर बार switch statement का नया block run होता है |जैसे
i=1 होने पर , What is national animal of india ? question प्लेयर के सामने आता है |अगर प्लेयर सही जवाब दे देता है तब counter variable’c’ की value मे increment होता है |
i=1 होने पर , How many paragraphs had taken as national song ‘vande Mataram’ ? question प्लेयर के सामने आता है |अगर प्लेयर सही जवाब दे देता है तब counter variable’c’ की value मे फिर से increment होता है | अगर प्लेयर गलत जवाब देगा तब counter c की value पुरानी ही रहेगी |
इस प्रोसेस सभी 10 questions के साथ चलेगी और counter ‘c’ की value प्लेयर द्वारा दिए गये सही answers की सख्या को बताएगा |
अब इस counter ‘c’ की value के आधार पर हम तीन message print करा सकते है |
अगर score=(float)c*10; की value ‘0’ और ‘100’ के बीच होगी तब first message print होगा |
अगर score=(float)c*10; की value 100 हुई तो दूसरा message print होगा |
अगर score=(float)c*10; की value उपर दी गई condition को फॉलो नहीं करता तब third message print होगा |
यहाँ पर toupper() function : अगर प्लेयर द्वारा दिए गये input small alphabets मे होते है तब इस function से input को upper case मे change कर देते है |
Source Code :
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<string.h>
void dispaly_record();
void save_score(float , char []);
int main()
{
int r,c,i,n;
float score;
char choice;
char name[20];
home:
system(“cls”);
printf(“Welcome !”)
printf(“Ready For Play Game”)
printf(“\n\t\t________________________________________”);
printf(“\n\t\t -> Press S to start the game”);
printf(“\n\t\t -> Press D to view the highest score  “);
printf(“\n\t\t -> Press Q to quit             “);
printf(“\n\t\t________________________________________\n\n”);
for(i=00;i<12;i++)
{}
choice=toupper(getch());
if (choice==’D’){
dispaly_record();
goto home; }
else if (choice==’Q’)
exit(1);
else if(choice==’S’){
system(“cls”);
printf(“Enter Your Name”);
gets(name);
system(“cls”);
printf(“\n ——————  Welcome %s to C Program Quiz Game ————————–“,name);
printf(“\n >>  In this game, you will be asked a total of 10 questions. You will be given 4 options and you have to press A, B ,C or D for the right option.”);
printf(“Enter ‘Y’ for Play game “);
printf(“Enter Any key for not play”);
if (toupper(getch())==’Y’){
goto home 2;
}
else{
goto home;
system(“cls”);
}
home 2:
system(“cls”);
c=0;
for(i=1;i<=10;i++)
{
system(“cls”);
r=i;
switch(r)
{
case 1:
printf(“\n\n What is national animal of india ? “);
printf(“\n\nA.Lion\t\tB.Tiger\n\nC.Horse\t\tD.Cow”);
if (toupper(getch())==’A’)
{
printf(“\n\nCorrect!!!”);c++;
getch();
break;
}
else
{
printf(“\n\nWrong!!! The correct answer is A.Lion”);
getch();
break;
}
case 2:
printf(“\n\n\n How many paragraphs had taken as national song ‘vande Mataram’ ?”);
printf(“\n\nA.4\t\tB.3\n\nC.2\t\tD.1”);
if (toupper(getch())==’C’)
{
printf(“\n\nCorrect!!!”);c++;
getch();
break;}
else
{
printf(“\n\nWrong!!! The correct answer is C.2”);
getch();
break;}
case 3:
printf(“\n\n\nWhich state of India has highest population ?”);
printf(“\n\nA.Rajasthan\t\tB.Uttar Pradesh\n\nC.Bihar\t\tD.West Bengal”);
if (toupper(getch())==’B’)
{
printf(“\n\nCorrect!!!”);c++;
getch();
break;}
else
{
printf(“\n\nWrong!!! The correct answer is B.Uttar Pradesh”);
getch();
break;}
case 4:
printf(“\n\n\nWho is first indian who win oscar award?”);
printf(“\n\nA.Bhanu Athaiya\t\tB.Sayjeet De Ray\n\nC.AR Rahman\t\tD.Gulzar”);
if (toupper(getch())==’A’)
{printf(“\n\nCorrect!!!”);c++;
getch();
break;
}
else
{
printf(“\n\nWrong!!! The correct answer is A.Bhanu Athaiya”);
getch();
break;}
case 5:
printf(“\n\n\nWhich is largest cry of world ?”);
printf(“\n\nA.Germanyt \t\tB.Rusia\n\nC.America\t\tD.Asia”);
if (toupper(getch())==’B’)
{
printf(“\n\nCorrect!!!”);c++;
getch();
break;}
else
{
printf(“\n\nWrong!!! The correct answer is B.Rusia”);
getch();
break;}
case 6:
printf(“\n\n\nWhat is the name of first computer?”);
printf(“\n\nA.ATARIS\t\tB.ENIAC\n\nC.TANDY\t\tD.NOVELLA”);
if (toupper(getch())==’B’ )
{printf(“\n\nCorrect!!!”);c++;
getch();
break;}
else
{
printf(“\n\nWrong!!! The correct answer is B.ENIAC”);
getch();
break;}
case 7:
printf(“\n\n\n Whose autobiagraphy nammed Mein Kampf…….”);
printf(“\n\nA.Adolf Hilter\t\tB.Barack Obama\n\nC.Abraham Lincoln\t\tD.Nelson Mandela”);
if (toupper(getch())==’A’ )
{printf(“\n\nCorrect!!!”);c++;
getch();
break;}
else
{
printf(“\n\nWrong!!! The correct answer is A.Adolf Hilter”);
getch();
break;}
case 8:
printf(“\n\n\nWho is first home minister of independent india?”);
printf(“\n\nA.Sardar Patel\t\tB\t\tB.John Mathai\n\nC.Dr.S.P. Mukherjee\t\tD.Khurshed lal”);
if (toupper(getch())==’A’ )
{
printf(“\n\nCorrect!!!”);c++;
getch();
break;}
else
{
printf(“\n\nWrong!!! The correct answer is A.Sardar Patel”);
getch();
break;}
case 9:
printf(“\n\n\n Which country is inventor of paper?”);
printf(“\n\nA.India\t\tB.China\n\nC.Rusia\t\tD.France”);
if (toupper(getch())==’A’ )
{printf(“\n\nCorrect!!!”);c++;
getch();
break;}
else
{printf(“\n\nWrong!!! The correct answer is D.China”);
getch();
break;}
case 10:
printf(“\n\n\n Where is longest street named Yonge Street?”);
printf(“\n\nA.HongKone\t\tB.Thailand \n\nC.India\t\tD.Canada”);
if (toupper(getch())==’D’ )
{printf(“\n\nCorrect!!!”);c++;
getch();
break;}
else
{
printf(“\n\nWrong!!! The correct answer is D.Canada”);
getch();
break;}}
}
system(“cls”);
score=(float)c*10;
if(score>0.00 && score<100)
{
printf(“\n\n\t\t**************** CONGRATULATION *****************”);
printf(“\n\t You won $%.2f”,score);goto go;}
else if(score==100)
{
printf(“\n\n\n \t\t**************** CONGRATULATION ****************”);
printf(“You answered all questions correct”);
printf(“\n\t\t You won $%.2f”,score);
printf(“\t\t Thank You!!”); }
else
{
printf(“\n\n\t******** SORRY YOU DIDN’T WIN ANY POINT ********”);
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
{
save_score(score,name);
goto home;}}}
void display_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 save_score(float score, char sco[20])
{system(“cls”);
float sc;
char m[20];
FILE *f;
f=fopen(“score.txt”,”r”);
fscanf(f,”%s%f”,&m,&sc);
if (score>=sc)
{ sc=score;
fclose(f);
f=fopen(“score.txt”,”w”);
fprintf(f,”%s\n%.2f”,sco,sc);
fclose(f);}}