128k views
2 votes
CHALLENGE ACTIVITY

Printing a message with ints and chars.
Print a message telling a user to press the letterToQuit key numPresses times to quit. End with newline. Ex: If letterToQuit = 'q' and numPresses = 2, print:
Press the q key 2 times to quit.
1 #include
2
3 int main(void)
10
11 return;
12

User Ethanneff
by
6.0k points

1 Answer

3 votes

Answer:

Write the following statement on line 9 or 10

printf("Press the %s key %d times to quit\\", &letterToQuit,numPresses);

Step-by-step explanation:

printf("Press the %s key %d times to quit\\", &letterToQuit,numPresses);

The above print statements is divided into literals and variables.

The literals are constant, and they are placed in " "

While the variables are used just the way they were declared

The literals in the print statement are:

"Press the", "key" and "times to quit\\"

The variables are:

letterToQuit and numPresses

The variables are printed between the literals to generate the required output.

\\ stands for new line

User MetaSnarf
by
5.2k points