diff --git a/src/main/quizproject.c b/src/main/quizproject.c index 4d381c7..618cae7 100644 --- a/src/main/quizproject.c +++ b/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(){ @@ -2744,7 +2769,8 @@ int main(int argc, char *argv[]) { printf("11. Play Geography Quiz!\n"); printf("12. Mini-Game: Guess the animal!\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: "); scanf("%d", &choice); v_progress_bar(argc,argv); @@ -2803,6 +2829,10 @@ int main(int argc, char *argv[]) { jump_to_menu = 1; break; case 14: + b_guessbirthyear(); + jump_to_menu = 1; + break; + case 15: printf("\nThank you for trying our C code!\n"); break; default: diff --git a/src/main/quizproject.h b/src/main/quizproject.h index 88c0b08..0da448e 100644 --- a/src/main/quizproject.h +++ b/src/main/quizproject.h @@ -107,6 +107,9 @@ void b_guess_animal(); //Basketball Quiz Headers void b_basketballQuiz(); +//Guess Birth Year Headers +void b_guessbirthyear(); + #define NUM_QUESTIONS 5 #define NUM_ROUNDS 15