Browse Source

Refactoring: Added one more question. Capital of Thailand.

main
fdlt3885 2 years ago
parent
commit
59af38c864
  1. 12
      src/main/quizproject.c

12
src/main/quizproject.c

@ -9,9 +9,9 @@ char answers[NUM_QUESTIONS] = {'B', 'A'};
int* randomNumber() { int* randomNumber() {
srand(time(NULL)); srand(time(NULL));
int k = 0, p; int k = 0, p;
static int arr[9];
while(k<9){
int num =rand()%9;
static int arr[10];
while(k<10){
int num =rand()%10;
for (p = 0; p < k; p++){ for (p = 0; p < k; p++){
if(arr[p]==num){ if(arr[p]==num){
break; break;
@ -105,6 +105,7 @@ void fifty_fifty(int question_num) {
"A.Alaska\nB.Washington", "A.Alaska\nB.Washington",
"C.Toronto\nD.Ottawa", "C.Toronto\nD.Ottawa",
"A.Egypt\nB.Mexico", "A.Egypt\nB.Mexico",
"A.Surat Thani\nB.Bangkok",
}; };
printf("%s\n",qC[question_num]); printf("%s\n",qC[question_num]);
} }
@ -234,6 +235,7 @@ void ask_questions(void) {
"What U.S. state is home to no documented poisonous snakes?\n", "What U.S. state is home to no documented poisonous snakes?\n",
"What is the capital of Canada?\n", "What is the capital of Canada?\n",
"What country are the Great Pyramids of Giza located in?\n", "What country are the Great Pyramids of Giza located in?\n",
"What is the capital of Thailand?\n",
}; };
char qC[][100] = {//6 char qC[][100] = {//6
@ -246,6 +248,7 @@ void ask_questions(void) {
"A.Alaska\nB.Washington\nC.Ohio\nD.California", "A.Alaska\nB.Washington\nC.Ohio\nD.California",
"A.Vancouver\nB.Montreal\nC.Toronto\nD.Ottawa", "A.Vancouver\nB.Montreal\nC.Toronto\nD.Ottawa",
"A.Egypt\nB.Mexico\nC.Iceland\nD.Greenland", "A.Egypt\nB.Mexico\nC.Iceland\nD.Greenland",
"A.Surat Thani\nB.Bangkok\nC.Phuket\nD.Pattaya City",
}; };
@ -260,6 +263,7 @@ void ask_questions(void) {
'A', 'A',
'D', 'D',
'A', 'A',
'B',
}; };
int* arr = randomNumber(); int* arr = randomNumber();
@ -392,7 +396,7 @@ void hint(int question_num) {
"Hint:It is the coldest state in the US.", "Hint:It is the coldest state in the US.",
"Hint:It is the 4th largest city in Canada.", "Hint:It is the 4th largest city in Canada.",
"Hint:It is a dry Country.", "Hint:It is a dry Country.",
"Hint:The capital has the longest city name in the world.",
}; };
printf("%s\n",qC[question_num]); printf("%s\n",qC[question_num]);
} }

Loading…
Cancel
Save