Browse Source

Added a Geography Quiz Game

main
fdlt3885 2 years ago
parent
commit
b92030e73b
  1. 53
      src/main/quizproject.c
  2. 6
      src/main/quizproject.h

53
src/main/quizproject.c

@ -2110,6 +2110,52 @@ void b_epic_game() {
B_write_review();
}
//geography quiz//
void b_WelcomeMessage() {
printf("Welcome to the geography quiz game!\n");
printf("Let's test your knowledge of geography!\n");
}
int b_askQuestion(int questionNumber, char* question, char* answer) {
char userAnswer[100];
printf("Question %d: %s\n", questionNumber, question);
printf("Your answer: ");
scanf("%s", userAnswer);
return strcmp(userAnswer, answer) == 0;
}
void b_displayResults(int correctAnswers) {
printf("You got %d out of 10 questions correct.\n", correctAnswers);
if (correctAnswers >= 8) {
printf("Excellent performance! You are a geography master!\n");
} else if (correctAnswers >= 5) {
printf("Good job! You know a fair bit about geography!\n");
} else {
printf("You need to brush up on your geography. Keep trying!\n");
}
}
void b_play_geography(){
int correctAnswers = 0;
b_WelcomeMessage();
correctAnswers += b_askQuestion(1, "What is the capital of France?", "Paris");
correctAnswers += b_askQuestion(2, "What is the largest ocean in the world?", "Pacific");
correctAnswers += b_askQuestion(3, "What is the currency of Japan?", "Yen");
correctAnswers += b_askQuestion(4, "What is the tallest mountain in the world?", "Everest");
correctAnswers += b_askQuestion(5, "What is the longest river in Africa?", "Nile");
correctAnswers += b_askQuestion(6, "What is the capital of China?", "Beijing");
correctAnswers += b_askQuestion(7, "What is the currency of the European Union?", "Euro");
correctAnswers += b_askQuestion(8, "What is the capital of Australia?", "Canberra");
correctAnswers += b_askQuestion(9, "What is the largest desert in the world?", "Sahara");
correctAnswers += b_askQuestion(10, "What is the capital of India?", "New Delhi");
b_displayResults(correctAnswers);
}
void v_play_rockpapersciss(){
int player_choice, computer_choice, player_score = 0, computer_score = 0;
srand(time(NULL));
@ -2580,7 +2626,8 @@ int main(int argc, char *argv[]) {
printf("8. Rock,Paper,Scissors!\n");
printf("9. Math Quiz\n");
printf("10. Check your Horoscope!\n");
printf("11. Exit\n");
printf("11. Play Geography Quiz!\n");
printf("12. Exit\n");
printf("Enter your choice: ");
scanf("%d", &choice);
v_progress_bar(argc,argv);
@ -2627,6 +2674,10 @@ int main(int argc, char *argv[]) {
jump_to_menu = 1;
break;
case 11:
b_play_geography();
jump_to_menu = 1;
break;
case 12:
printf("\nThank you for trying our C code!\n");
break;
default:

6
src/main/quizproject.h

@ -95,6 +95,12 @@ void B_saythankyou(void);
void rate(void);
void B_write_review(void);
//Geography quiz headers
void b_WelcomeMessage();
int b_askQuestion(int questionNumber, char* question, char* answer);
void b_displayResults(int correctAnswers);
void b_play_geography();
#define NUM_QUESTIONS 5
#define NUM_ROUNDS 15

Loading…
Cancel
Save