Solution for Exercise 7-11

ex0711

#include <stdio.h>

int main()
{
    char prompt[] = "Program to Destroy the World\nPress Enter to explode:";

    printf("%s",prompt);
    getchar();
    return(0);
}

Notes

* The newline character, \n, can fit into a string in any spot.

* The reason the prompt string doesn't terminate with a newline is that the output looks better without one. Computer users are conditioned to seeing a prompt followed by a flashing cursor. Otherwise, if you ended the prompt string with a newline, the cursor would appear on the following line. That's okay, but it's not the way most programs present themselves.

* Even though two lines are displayed, you need only one %s placeholder in the printf() function to display the string. The newline is just a character; it doesn't split the string into two pieces.