Question

Write a C program that plays a game of ​Mad Libs​ with the user. Specifically, the...

Write a C program that plays a game of ​Mad Libs​ with the user. Specifically, the program should do the following:

a. Declare five character arrays of size 20.

b. Prompt the user, five times, to enter a word of some type. Each word is stored in a different character array. The word types could be vague, such as "noun," "adjective," or "adverb," or they could be specific, such as "color," "animal," or "name."

c. Using printf()'s %s format specifier, output a short story that includes each of these five words.

The story told by the program can be anything you want. Below is a sample story that you're welcome to use. The words that will be replaced with inputs are shown in italics.
"Every morning, ​name ​ gets out of bed and ready for class. ​Name ​ eats ​food ​ for breakfast, then pets their ​animal ​ and ​verb ​ s​ ​ their teeth. After ​name ​ puts on ​noun ​ , ​name ​ is ready to go."

A sample run of the program with "Munster," "tuna," "human," "sharpen," and "attitude" as user inputs might look like the following:

Welcome to Mad Libs!

Enter a name: ​Munster

Enter a food: ​tuna

Enter an animal: ​human

Enter a verb: ​sharpen

Enter a noun: ​attitude

Every morning, Munster gets out of bed and ready for class. Munster eats tuna for breakfast, then pets their human and sharpens​ ​ their teeth. After Munster puts on attitude, Munster is ready to go.

Homework Answers

Answer #1


#include <stdio.h>

int main(void) {
char name[20], food[20], animal[20], verb[20], noun[20];

printf("Welcome to Mad Libs!\nEnter a name: ");
scanf("%s", name);
printf("Enter a food: ");
scanf("%s", food);
printf("Enter a animal: ");
scanf("%s", animal);
printf("Enter a verb: ");
scanf("%s", verb);
printf("Enter a noub: ");
scanf("%s", noun);

printf("Every morning, %s gets out of bed and ready for class. Munster eats %s for breakfast, then pets their %s and %ss​ ​ their teeth. After Munster puts on %s, %s is ready to go.", name, food, animal, verb, noun, name);
return 0;
}


// Hit the thumbs up if you are fine with the answer. Happy Learning!

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Using Python, students will use variables, input, and printing to create a Mad Lib. The program...
Using Python, students will use variables, input, and printing to create a Mad Lib. The program will print out the title of the Mad Libs story, as well as a short explanation of game play: The program should then prompt the user to enter in nouns, verbs, adjectives, proper nouns, and adverbs: Enter a proper noun: Enter a place: Enter another place: Enter an adverb: Enter a noun: Enter an adjective: Enter an adverb: Enter a verb: Enter a place:...
Write a program that plays a number guessing game with a human user. The human user...
Write a program that plays a number guessing game with a human user. The human user will think of a number between 1 and 100, inclusive. Then the program has to guess what the user entered. keep track of the number of interaction it takes for the computer to guess the number. sample run: enter number to be guessed:88 output: you entered 88, and it took the program 3 iterations to guess.
Write a Python program that plays a number guessing game with a human user. The human...
Write a Python program that plays a number guessing game with a human user. The human user will think of a number between 1 and 100, inclusive. Then the program has to guess what the user entered. keep track of the number of interaction it takes for the computer to guess the number. sample run: enter number to be guessed:88 output: you entered 88, and it took the program 3 iterations to guess.
Write a C program that allows the user to balance a credit card account. The program...
Write a C program that allows the user to balance a credit card account. The program should first prompt the user to enter the Bank Name, and the beginning balance of his/her credit card account (must allow for dollars and cents). The program should then prompt the user to enter the number of refunds to be posted, and then the number of payments to be posted, and then the number of charges to be posted. For this assignment, let's set...
Program Behavior Each time your program is run, it will prompt the user to enter the...
Program Behavior Each time your program is run, it will prompt the user to enter the name of an input file to analyze. It will then read and analyze the contents of the input file, then print the results. Here is a sample run of the program. User input is shown in red. Let's analyze some text! Enter file name: sample.txt Number of lines: 21 Number of words: 184 Number of long words: 49 Number of sentences: 14 Number of...
In Python write a program that prompts the user for a file name, make sure the...
In Python write a program that prompts the user for a file name, make sure the file exists and if it does reads through the file, count the number of times each word appears and then output the word count in a sorted order from high to low. The program should: Display a message stating its goal Prompt the user to enter a file name Check that the file can be opened and if not ask the user to try...
The Problem Write a C or C++ program which performs specific operations on bits. The user...
The Problem Write a C or C++ program which performs specific operations on bits. The user will specify a value The user can then set, test, or toggle individual bits in the initial value. Input Your program will prompt the user for: An inital value in hexadecimal. This value may be up to 32 bits (eight hexadecimal digits) long. If the user-supplied value is less than eight characters in length, assume the additional digits are zero and are on the...
For a C program hangman game: Create the function int setup_game [int setup_game ( Game *g,...
For a C program hangman game: Create the function int setup_game [int setup_game ( Game *g, char wordlist[][MAX_WORD_LENGTH], int numwords)] for a C program hangman game. (The existing code for other functions and the program is below, along with what the function needs to do) What int setup_game needs to do setup_game() does exactly what the name suggests. It sets up a new game of hangman. This means that it picks a random word from the supplied wordlist array and...