In C coding, mad libs are activities that have a person provide various words, which are then used to complete a short story in unexpected (and hopefully funny) ways.

Write a program that takes a string and an integer as input, and outputs a sentence using the input values as shown in the example below. The program repeats until the input string is quit and disregards the integer input that follows. Assume the input string does not contain spaces

Ex: If the input is:

apples 5
shoes 2
quit 0
the output is:

Eating 5 apples a day keeps you happy and healthy.
Eating 2 shoes a day keeps you happy and healthy.

#include
#include

int main(void) {
char userString[50];
int userNum;

/* Type your code here. */

return 0;
}

Respuesta :

umm You should have put this in writing

The program illustrates the use of repetitive operations.

The program will be completed in C++, because the program segment provided in the question, was written in C++.

Replace /* Type your code here. */ with the following lines of code

//This gets input for userString

std::cin>>userString;

//This gets input for userNum

std::cin>>userNum;

//The following loop is repeated until the input is "quit"

while(std::strcmp(userString,"quit") != 0){

//This prints the required string

   std::cout<<"Eating "<<userNum<<" "<<userString<<" a day keeps you happy and healthy.\n";

//This gets another input for userString, while the loop is active

   std::cin>>userString;

//This gets another input for userNum, while the loop is active

   std::cin>>userNum;

}

The program keeps getting input from the user until the input is "quit"

The complete program without comments is:

#include <iostream>

#include <cstring>

int main(void) {

char userString[50];

int userNum;

std::cin>>userString;

std::cin>>userNum;

while(std::strcmp(userString,"quit") != 0){

   std::cout<<"Eating "<<userNum<<" "<<userString<<" a day keeps you happy and healthy.\n";

   std::cin>>userString;

   std::cin>>userNum;

}

return 0;

}

See attachment for sample run

Read more about C++ programs at:

https://brainly.com/question/17584261

Ver imagen MrRoyal