A Program Without Output Doesn't Do Much

One of the important characteristics of algorithms is that they must have at least one output. So we'll begin looking at what can be done by C programs by looking at how we can produce output.

In our "Hello World" program, the statement that produces output is


printf("Hello World\n");

The first thing to note is that printf() is a function. (We first looked at those in Part 1-2 .) Even this simple example illustrates a number of things about using functions:
  1. To get the function to do something for us, we need to call it.
  2. If inside of a function, we have a function name followed by parentheses (empty or not), then it calls the function. (Notice that the function we're calling may actually be the one we're in. That's recursion and we'll talk about that more later.)
  3. We might have stuff inside the parentheses. Such things are called arguments or parameters. We'll see about them later too.
  4. The first argument to printf is something that's actually printed out on the screen.
  5. We can include special characters in these literal strings like \n which means to put a newline into the output. Putting it at the end of the output like this makes any output that follows appear on the next line.
  6. We normally end a printf() with a semicolon.

What statement would you give to print out Hello and World on separate lines?