Browse Source

Refactoring: Added questions and hard questions

main
fdlt3859 2 years ago
parent
commit
67eade418d
  1. 29
      src/main/quizproject.c

29
src/main/quizproject.c

@ -9,9 +9,9 @@
int* randomNumber() { int* randomNumber() {
srand(time(NULL)); srand(time(NULL));
int k = 0, p; int k = 0, p;
static int arr[5];
while(k<5){
int num =rand()%5;
static int arr[6];
while(k<6){
int num =rand()%6;
for (p = 0; p < k; p++){ for (p = 0; p < k; p++){
if(arr[p]==num){ if(arr[p]==num){
break; break;
@ -87,7 +87,7 @@ void correct(int score2){
printf("You have %d points now\n\n", score); printf("You have %d points now\n\n", score);
} }
void wrong(int score1){ void wrong(int score1){
printf("\nwrong!\n");
printf("\nWrong!\n");
printf("You have %d points now\n\n", score); printf("You have %d points now\n\n", score);
} }
@ -96,6 +96,9 @@ void fifty_fifty(int question_num) {
"A.Mount Everest\nB.Uludag", "A.Mount Everest\nB.Uludag",
"A.USA\nB.China", "A.USA\nB.China",
"C.Amazon River\nD.The Nile River", "C.Amazon River\nD.The Nile River",
"A.San Fransisco\nB.San Diego",
"C.Merida\nD.Mexico city",
"C.Russia\nD.USA\n",
}; };
printf("%s\n",qC[question_num]); printf("%s\n",qC[question_num]);
} }
@ -141,7 +144,7 @@ int k = 0;
printf("\t\t--------------------Round 1-------------------\n\n"); printf("\t\t--------------------Round 1-------------------\n\n");
printf(">>In this round you need to answer 3 questions correctly to move to Round 2<<\n\n"); printf(">>In this round you need to answer 3 questions correctly to move to Round 2<<\n\n");
int initial = 0, end = 1;
int initial = 0, end = 2;
printOutOption(qS,qC,aS,initial,end,randArr); printOutOption(qS,qC,aS,initial,end,randArr);
if (score < 1) { if (score < 1) {
@ -151,7 +154,7 @@ int k = 0;
printf("\t\t--------------------Round 2-------------------\n\n"); printf("\t\t--------------------Round 2-------------------\n\n");
printf(">>In this round you need to answer 2 questions correctly to move to Round 3<<\n\n"); printf(">>In this round you need to answer 2 questions correctly to move to Round 3<<\n\n");
initial = 1, end = 3;
initial = 2, end = 4;
printOutOption(qS,qC,aS,initial,end,randArr); printOutOption(qS,qC,aS,initial,end,randArr);
} }
@ -162,7 +165,7 @@ int k = 0;
printf("\t\t--------------------Round 3-------------------\n\n"); printf("\t\t--------------------Round 3-------------------\n\n");
printf(">>In this round you need to answer 2 questions correctly to move to Round 4<<\n\n"); printf(">>In this round you need to answer 2 questions correctly to move to Round 4<<\n\n");
initial = 3, end = 5;
initial = 4, end = 6;
printOutOption(qS,qC,aS,initial,end,randArr); printOutOption(qS,qC,aS,initial,end,randArr);
} }
@ -182,6 +185,7 @@ void ask_questions(void) {
"What is the name of the longest river in Africa?\n", "What is the name of the longest river in Africa?\n",
"What American city is the Golden Gate Bridge located in?\n", "What American city is the Golden Gate Bridge located in?\n",
"What is the capital of Mexico?\n", "What is the capital of Mexico?\n",
"What is the name of the largest country in the world?\n",
}; };
char qC[][100] = {//6 char qC[][100] = {//6
@ -190,6 +194,7 @@ void ask_questions(void) {
"A.Missisipi River\nB.Yangtze River\nC.Amazon River\nD.The Nile River", "A.Missisipi River\nB.Yangtze River\nC.Amazon River\nD.The Nile River",
"A.San Fransisco\nB.San Diego\nC.New York\nD.Los Angeles", "A.San Fransisco\nB.San Diego\nC.New York\nD.Los Angeles",
"A.Oaxaca\nB.Puebla\nC.Merida\nD.Mexico city", "A.Oaxaca\nB.Puebla\nC.Merida\nD.Mexico city",
"A.India\nB.China\nC.Russia\nD.USA",
}; };
@ -200,6 +205,7 @@ void ask_questions(void) {
'D', 'D',
'A', 'A',
'D', 'D',
'C',
}; };
@ -220,12 +226,12 @@ void ask_hard_questions(void) {
char questions[NUM_QUESTIONS][256] = { char questions[NUM_QUESTIONS][256] = {
"What is the capital of France?",
"Who was the first president of the United States?"
"Which author is famed for her detective novels about Hercule Poirot and Miss Marple?",
"Atticus Finch is one of the main characters in which novel from 1960?"
}; };
char options[NUM_QUESTIONS][4][256] = { char options[NUM_QUESTIONS][4][256] = {
{ "A) Berlin", "B) Paris", "C) London", "D) Rome" },
{ "A) George Washington", "B) John Adams", "C) Thomas Jefferson", "D) James Madison" }
{ "A) Arthur Conan Doyle", "B) Agatha Christie", "C) Charles Dickens", "D) Stephen King" },
{ "A) To Kill a Mockingbird", "B) Pride and Prejudice", "C) The Great Gatsby", "D) Jane Eyre" }
}; };
char answers[NUM_QUESTIONS] = { 'B', 'A'}; // correct answers (A, B, C, or D) char answers[NUM_QUESTIONS] = { 'B', 'A'}; // correct answers (A, B, C, or D)
@ -289,6 +295,7 @@ void hint(int question_num) {
"Hint:The longest river measures 6,650km.", "Hint:The longest river measures 6,650km.",
"Hint:The Golden States Warriors play there.\n", "Hint:The Golden States Warriors play there.\n",
"Hint:It is one of the oldest and largest cities in the Americas.\n", "Hint:It is one of the oldest and largest cities in the Americas.\n",
"Hint:The area of the largest country is 17.1 million km2.\n",
}; };
printf("%s\n",qC[question_num]); printf("%s\n",qC[question_num]);
} }

Loading…
Cancel
Save