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
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:
- To get the function to do something for us, we need to call it.
- If inside of a function, we have a function name followed by parentheses (empty or not),
that is 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
- We might have stuff inside the parentheses. Such things are called arguments or
parameters. We'll see about them later too.
- The first argument to printf is something that's actually printed out on the screen.
- 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.
- We normally end a
printf() with a semicolon.
What statement would you give to print out Hello and World on separate lines?