Browse Source

Added Basketball Quiz and header

main
fdlt3885 2 years ago
parent
commit
62495c8661
  1. 88
      src/main/quizproject.c
  2. 3
      src/main/quizproject.h

88
src/main/quizproject.c

@ -2189,6 +2189,87 @@ void b_guess_animal() {
printf("---Thank you for Playing Guess The Animal---\n\n"); printf("---Thank you for Playing Guess The Animal---\n\n");
} }
//Basketball Quiz
void b_basketballQuiz() {
int score = 0;
char answer[20];
printf("Welcome to the basketball quiz game!\n");
printf("Answer each question with 'yes' or 'no'.\n");
printf("\nQuestion 1: Is basketball a sport played with a ball and a hoop?\n");
printf("Answer: ");
scanf("%s", answer);
if (strcmp(answer, "yes") == 0)
{
printf("Correct!\n");
score++;
}
else
{
printf("Incorrect.\n");
}
printf("\nQuestion 2: Is the height of a basketball hoop 10 feet?\n");
printf("Answer: ");
scanf("%s", answer);
if (strcmp(answer, "no") == 0)
{
printf("Correct!\n");
score++;
}
else
{
printf("Incorrect.\n");
}
printf("\nQuestion 3: Is the term 'slam dunk' used in basketball?\n");
printf("Answer: ");
scanf("%s", answer);
if (strcmp(answer, "yes") == 0)
{
printf("Correct!\n");
score++;
}
else
{
printf("Incorrect.\n");
}
printf("\nQuestion 4: Can a player run with the ball in basketball?\n");
printf("Answer: ");
scanf("%s", answer);
if (strcmp(answer, "no") == 0)
{
printf("Correct!\n");
score++;
}
else
{
printf("Incorrect.\n");
}
printf("\nQuestion 5: Is the 3-point line closer to the basket in basketball than the free-throw line?\n");
printf("Answer: ");
scanf("%s", answer);
if (strcmp(answer, "yes") == 0)
{
printf("Correct!\n");
score++;
}
else
{
printf("Incorrect.\n");
}
printf("\nYou got %d out of 5 questions correct!\n", score);
printf("Thanks for playing the basketball quiz game! Goodbye!\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;
@ -2662,7 +2743,8 @@ int main(int argc, char *argv[]) {
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. Mini-Game: Guess the animal!\n"); printf("12. Mini-Game: Guess the animal!\n");
printf("13. Exit\n");
printf("13. Basketball Quiz!\n");
printf("14. 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);
@ -2717,6 +2799,10 @@ int main(int argc, char *argv[]) {
jump_to_menu = 1; jump_to_menu = 1;
break; break;
case 13: case 13:
b_basketballQuiz();
jump_to_menu = 1;
break;
case 14:
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

@ -104,6 +104,9 @@ void b_play_geography();
//Guess animal Game Headers //Guess animal Game Headers
void b_guess_animal(); void b_guess_animal();
//Basketball Quiz Headers
void b_basketballQuiz();
#define NUM_QUESTIONS 5 #define NUM_QUESTIONS 5
#define NUM_ROUNDS 15 #define NUM_ROUNDS 15

Loading…
Cancel
Save