I need Help with this using the C# program Write a “quiz” program on a topic, ab
ID: 3867964 • Letter: I
Question
I need Help with this using the C# program
Write a “quiz” program on a topic, about which you are knowledgeable. This quiz can be work related, general knowledge or any set of questions where there is a specific answer. Ignore questions where long descriptions or general answers needed. The program should display the questions, one at a time, and possible answers, and accept an answer from the user. If the answer is correct, the program should go on to the next question. If it is incorrect, store the question for the second attempt and go on to the next question. When the list of questions has ended, the questions that were missed previously, or answered incorrectly, should be displayed again, in their original order. Keep a count of the correct answers for each category of questions and display the final count after two attempts. Also, display the correct answer, when necessary, in the second round of questioning.
Limit the quiz to ten (10) questions. Include questions from both true/false and multiple-choice categories. Four (4) possible answers should be listed in multiple-choice questions.
Explanation / Answer
#include<stdio.h>
#include<conio.h>
#include <windows.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(" ");
printf(" %s has secured the Highest Score %.2f",name,s);
printf(" ");
fclose(f);
getch();
}
void help()
{
system("cls");
printf(" This game is very easy to play. You'll be asked some general");
printf(" knowledge questions and the right answer is to be chosen among");
printf(" the four options provided. Your score will be calculated at the");
printf(" end. Remember that the more quicker you give answer the more");
printf(" score you will secure. Your score will be calculated and displayed");
printf(" at the end and displayed. If you secure highest score, your score");
printf(" will be recorded. So BEST OF LUCK.");
}
void writescore(float score, char plnm[20])
{
float sc;
char nm[20];
FILE *f;
system("cls");
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 %.2f",plnm,sc);
fclose(f);
}
}
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(" WELCOME TO I.Q. TEST PROGRAM ") ;
puts(" -------------------------------");
puts(" Enter 'S' to start game ");
puts(" Enter 'V' to view high score ");
puts(" Enter 'H' for help ");
puts(" Enter 'Q' to quit ");
printf(" ------------------------------- ");
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(" Enter your name...");
printf(" (only one word) ");
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(" What is the maximum no. of asymptotes of the curve x^4+2x+6=0?");
printf(" A.4 B.3 C.none D.infinite ");
countq++;
if (toupper(getch())=='A')
{printf(" Correct!!!");countr++; break;}
else
{printf(" Wrong!!! The correct answer is A.4");break;}
case 2:
printf(" How many points are possible in a compound pendulum about which");
printf("time period is same?");
printf(" A.4 B.2 C.none D.infinite ");
countq++;
if (toupper(getch())=='A')
{printf(" Correct!!!");countr++; break;}
else
printf(" Wrong!!! The correct answer is A.4");
break;
case 3:
printf(" Who was the first US President?");
printf(" A.Richard Nikson B.Abraham Linkon C.John F. Kennedy D.George Washington ");
countq++;
if (toupper(getch())=='D')
{printf(" Correct!!!");countr++; break;}
else
{printf(" Wrong!!! The correct answer is D.George Washington");break;}
case 4:
printf(" Who was awarded the 'Man of the Tournament' of ICC WORLD CUP 2007?");
printf(" A.Glen Magrath B.Mahela Jawardan C.Mathew Hayden D.Sachin Tendulkar ");
countq++;
if (toupper(getch())=='A')
{printf(" Correct!!!");countr++; break;}
else
{printf(" Wrong!!! The correct answer is A.Glen Magrath");break;}
case 5:
printf(" Which country won the Fifa World Cup 1998?");
printf(" A.France B.Brazil C.Italy D.England ");
countq++;
if (toupper(getch())=='A')
{printf(" Correct!!!");countr++; break;}
else
{printf(" Wrong!!! The correct answer is A.France");break;}
case 6:
printf(" Which syllabe is stressed in the word 'democracy'?");
printf(" A.1st B.2nd C.3rd D.4th ");
countq++;
if (toupper(getch())=='B' )
{printf(" Correct!!!");countr++; break;}
else
{printf(" Wrong!!! The correct answer is B.2nd");break;}
case 7:
printf(" Which country was the winner of Cricket World Cup 1987?");
printf(" A.West Indies B.India C.Australia D.England ");
countq++;
if (toupper(getch())=='C')
{printf(" Correct!!!");countr++; break;}
else
{printf(" Wrong!!! The correct answer is C.Australia");break;}
case 8:
printf(" What is the height of Mount everest in feet?");
printf(" A.8648 B.6648 C.8884 D.8848 ");
countq++;
if (toupper(getch())=='D')
{printf(" Correct!!!");countr++; break;}
else
{printf(" Wrong!!!
The correct answer is D.8848");break;}
case 9:
printf(" What is the capital of Denmark?");
printf(" A.Copenhagen B.Helsinki C.Rome D.Madrid ");
countq++;
if (toupper(getch())=='A')
{printf(" Correct!!!");countr++; break;}
else
{printf(" Wrong!!! The correct answer is A.Copenhagen");break;}
case 10:
printf(" Which syllabe is stressed in the word 'instanteneous'?");
printf(" A.1st B.2nd C.3rd D.4th ");
countq++;
if (toupper(getch())=='C')
{printf(" Correct!!!");countr++; break;}
else
{printf(" Wrong!!! The correct answer is C.3rd");break;}
case 11:
printf(" Who was the only player to score 6 successive sixes in an over?");
printf(" A.Adam Gilchrist B.M.S.Dhoni C.Herschel Gibbs D.Sanath Jayasurya ");
countq++;
if (toupper(getch())=='C')
{printf(" Correct!!!");countr++; break;}
else
{printf(" Wrong!!! The correct answer is C.Herschel Gibbs");break;}
case 12:
printf(" Who was the only player to take 4 successive wickets?");
printf(" A.Malinga Bandara B.Lasith Malinga C.Bret Lee D.Murali Daran ");
countq++;
if (toupper(getch())=='B')
{printf(" Correct!!!");countr++; break;}
else
{printf(" Wrong!!! The correct answer is B.Lasith Malinga");break;}
case 13:
printf(" Which country is hosting the Fifa World Cup 2010?");
printf(" A.South Africa B.Italy C.Argentina D.Spain ");
countq++;
if (toupper(getch())=='A')
{printf(" Correct!!!");countr++; break;}
else
{printf(" Wrong!!! The correct answer is A.South Africa");break;}
case 14:
printf(" Who is the author of 'Pulpasa Cafe'?");
printf(" A.Narayan Wagle B.Lal Gopal Subedi C.B.P. Koirala D.Khagendra Sangraula ");
countq++;
if (toupper(getch())=='A')
{printf(" Correct!!!");countr++; break;}
else
{printf(" Wrong!!! The correct answer is A.Narayan Wagle");break;}
case 15:
printf(" Which country is Maria Sarapova from?");
printf(" A.Russia B.Switzerland C.Argentina D.Spain ");
countq++;
if (toupper(getch())=='A')
{printf(" Correct!!!");countr++; break;}
else
{printf(" Wrong!!! The correct answer is A.Russia");break;}
case 16:
printf(" Who was awarded the youngest player award in Fifa World Cup 2006?");
printf(" A.Wayne Rooney B.Lucas Podolski C.Lionel Messi D.Christiano Ronaldo ");
countq++;
if (toupper(getch())=='B')
{printf(" Correct!!!");countr++; break;}
else
{printf(" Wrong!!! The correct answer is B.Lucas Podolski");break;}
case 17:
printf(" What is the smallest district of Nepal?");
printf(" A.Lalitpur B.Karnali C.Bhaktapur D.Gulmi ");
countq++;
if (toupper(getch())=='C')
{printf(" Correct!!!");countr++; break;}
else
{printf(" Wrong!!! The correct answer is C.Bhaktapur");break;}
case 18:
printf(" What is the headquarter of Western Development Region?");
printf(" A.Dhankuta B.Kathmandu C.Dhangadhi D.Pokhara ");
countq++;
if (toupper(getch())=='D')
{printf(" Correct!!!");countr++; break;}
else
{printf(" Wrong!!! The correct answer is D.Pokhara");break;}
case 19:
printf(" Which place is called 'The Cherrapunji of Nepal'?");
printf(" A.Dharan B.Kathmandu C.Pokhara D.Butwal ");
countq++;
if (toupper(getch())=='C')
{printf(" Correct!!!");countr++; break;}
else
{printf(" Wrong!!! The correct answer is C.Pokhara");break;}
case 20:
printf(" Which city is known at 'The City of Seven Hills'?");
printf(" A.Rome B.Vactican City C.Madrid D.Berlin ");
countq++;
if (toupper(getch())=='A')
{printf(" Correct!!!");countr++; break;}
else
{printf(" Wrong!!! The correct answer is A.Rome");break;}
case 21:
printf(" Who was the F1 racing champion of 2006?");
printf(" A.Louis Hamilton B.Felipe Massa C.Fernando Alonso D.Michael Schumaker ");
countq++;
if (toupper(getch())=='C')
{printf(" Correct!!!");countr++; break;}
else
{printf(" Wrong!!! The correct answer is C.Fernanda Alonso");break;}
case 22:
printf(" Who won the Women Australian Open 2007?");
printf(" A.Martina Hingis B.Maria Sarapova C.Kim Clijster D.Serena Williams ");
countq++;
if (toupper(getch())=='D')
{printf(" Correct!!!");countr++; break;}
else
{printf(" Wrong!!! The correct answer is D.Serena Williams");break;}
case 23:
printf(" Name the country where there no mosquito is found?");
printf(" A.Germany B.Spain C.Japan D.France ");
countq++;
if (toupper(getch())=='D')
{printf(" Correct!!!");countr++; break;}
else
{printf(" Wrong!!! The correct answer is D.France");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(" Your Score: %.2f",score);
if (score==100) printf(" EXCELLENT!!! KEEP IT UP");
else if (score>=80 && score<100) printf(" VERY GOOD!!");
else if (score>=60 &&score<80) printf(" GOOD! BUT YOU NEED TO KNOW MORE.");
else if (score>=40 && score<60) printf(" SATISFACTORY RESULT, BUT THIS MUCH IS MUCH SUFFICIENT.");
else printf(" YOU ARE VERY POOR IN G.K.,WORK HARD");
puts(" NEXT PLAY?(Y/N)");
if (toupper(getch())=='Y')
goto home;
else
{
writescore(score,playername);
goto mainhome;
}
}
else
{
printf(" Enter the right key ");
Sleep(700);
goto mainhome;
}
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.