Browse Source

Added Guess Barack Obama's Birth year mini-game

main
fdlt3885 2 years ago
parent
commit
aede68e832
  1. 32
      src/main/quizproject.c
  2. 3
      src/main/quizproject.h

32
src/main/quizproject.c

@ -2269,6 +2269,31 @@ void b_basketballQuiz() {
} }
//Guess the birth year
void b_guessbirthyear()
{
int year = 1961;
int guess;
int tries = 0;
printf("Guess the year Barack Obama was born: ");
scanf("%d", &guess);
while (guess != year) {
if (guess < year) {
printf("Too low. Guess again: ");
} else if (guess > year) {
printf("Too high. Guess again: ");
}
scanf("%d", &guess);
tries++;
}
printf("Correct! It took you %d tries to guess the year.\n", tries);
}
void v_play_rockpapersciss(){ void v_play_rockpapersciss(){
@ -2744,7 +2769,8 @@ int main(int argc, char *argv[]) {
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. Basketball Quiz!\n"); printf("13. Basketball Quiz!\n");
printf("14. Exit\n");
printf("14. Guess Barack Obama's birth Year!\n");
printf("15. 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);
@ -2803,6 +2829,10 @@ int main(int argc, char *argv[]) {
jump_to_menu = 1; jump_to_menu = 1;
break; break;
case 14: case 14:
b_guessbirthyear();
jump_to_menu = 1;
break;
case 15:
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

@ -107,6 +107,9 @@ void b_guess_animal();
//Basketball Quiz Headers //Basketball Quiz Headers
void b_basketballQuiz(); void b_basketballQuiz();
//Guess Birth Year Headers
void b_guessbirthyear();
#define NUM_QUESTIONS 5 #define NUM_QUESTIONS 5
#define NUM_ROUNDS 15 #define NUM_ROUNDS 15

Loading…
Cancel
Save