Browse Source

Added Guess the Animal Mini Game

main
fdlt3885 2 years ago
parent
commit
807861120f
  1. 41
      src/main/quizproject.c
  2. 3
      src/main/quizproject.h

41
src/main/quizproject.c

@ -2155,6 +2155,40 @@ void b_play_geography(){
} }
//Guess animal Game
void b_guess_animal() {
char animal[20];
char user_input[20];
printf("---Welcome to Guess The Animal---\n\n");
printf("---Think of your favorite animal---\n\n");
printf("Is it a wild animal? (yes/no)\n");
scanf("%s", user_input);
if (strcmp(user_input, "yes") == 0) {
printf("Does it live in the jungle? (yes/no)\n");
scanf("%s", user_input);
if (strcmp(user_input, "yes") == 0) {
strcpy(animal, "tiger");
} else {
strcpy(animal, "gazelle");
}
} else {
printf("Is it a domesticated animal? (yes/no)\n");
scanf("%s", user_input);
if (strcmp(user_input, "yes") == 0) {
strcpy(animal, "cat");
} else {
strcpy(animal, "goldfish");
}
}
printf("Your favorite animal is a %s!\n", animal);
printf("---Thank you for Playing Guess The Animal---\n\n");
}
void v_play_rockpapersciss(){ void v_play_rockpapersciss(){
int player_choice, computer_choice, player_score = 0, computer_score = 0; int player_choice, computer_choice, player_score = 0, computer_score = 0;
@ -2627,7 +2661,8 @@ int main(int argc, char *argv[]) {
printf("9. Math Quiz\n"); printf("9. Math Quiz\n");
printf("10. Check your Horoscope!\n"); printf("10. Check your Horoscope!\n");
printf("11. Play Geography Quiz!\n"); printf("11. Play Geography Quiz!\n");
printf("12. Exit\n");
printf("12. Mini-Game: Guess the animal!\n");
printf("13. Exit\n");
printf("Enter your choice: "); printf("Enter your choice: ");
scanf("%d", &choice); scanf("%d", &choice);
v_progress_bar(argc,argv); v_progress_bar(argc,argv);
@ -2678,6 +2713,10 @@ int main(int argc, char *argv[]) {
jump_to_menu = 1; jump_to_menu = 1;
break; break;
case 12: case 12:
b_guess_animal();
jump_to_menu = 1;
break;
case 13:
printf("\nThank you for trying our C code!\n"); printf("\nThank you for trying our C code!\n");
break; break;
default: default:

3
src/main/quizproject.h

@ -101,6 +101,9 @@ int b_askQuestion(int questionNumber, char* question, char* answer);
void b_displayResults(int correctAnswers); void b_displayResults(int correctAnswers);
void b_play_geography(); void b_play_geography();
//Guess animal Game Headers
void b_guess_animal();
#define NUM_QUESTIONS 5 #define NUM_QUESTIONS 5
#define NUM_ROUNDS 15 #define NUM_ROUNDS 15

Loading…
Cancel
Save