In this assignment you will create a text-based game. Requirements: 1. Your game
ID: 3674115 • Letter: I
Question
In this assignment you will create a text-based game.
Requirements:
1. Your game must have at least four situations
a. Each situation must have a function that displays the specifics of the situation
b. Each situation must ask the user for a numeric choice such as 1-3 or 1-4. Each situation must call the same function, which should be named GetChoice() and take a min and max value.
c. Each situation must have a function that displays the results of the user choice.
d. You must keep score and display the score in a function called DisplayScore()
2. Your game must have a guessing game a function named DoGuessingGame() in it that asks users to guess a number from 5 to 25
a. Let the user know if their guess is too high or too low.
b. Keep track of the number of guesses.
c. Reward the player's score for fewer guesses
d. Display the score
3. Your game must include a four question quiz where you ask geography questions.
a. The functions and structure of this are up to you. Model the previous sections.
(i need help writing the c code for this. i use virtual studios)
Explanation / Answer
working c code for the game:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main(void) {
srand(time(NULL));
int r = rand() % 21 + 5;
int correct = 0;
int guess;
int counter = 0;
printf("Guess the number from 5-25 ");
do {
scanf("%d", &guess);
if (guess == r) {
counter++;
printf("You guessed correctly in %d tries! Congratulations! ", counter);
correct = 1;
}
if (guess < r) {
counter++;
printf("your guess is low. Please try again. ");
}
if (guess > r) {
counter++;
printf("Your guess is high. Please try again. ");
}
} while (correct == 0);
return 0;
}