Without further ado, here is the Hello, world! C program. It does no calculations, nor does it accept any input. It only displays a short greeting and then ends, as follows:
#include <stdio.h>
int main()
{
printf( "Hello, world!\n" );
return 0;
}
Some minor details of this program have changed since it was first introduced. What is here will build and run with all C compilers that have been created in the last 20 years.
Before we get into the details of what each part of this program does, see if you can identify which line of the program prints our greeting. You may find the punctuation peculiar; we will explain this in the next chapter. Notice how some punctuation marks come in pairs, while others do not. There are five paired and five unpaired punctuation marks in all. Can you identify them? (We are not counting the punctuation in the message "Hello, world!".)
There is another pairing in this simple program that is not obvious at this time, but one that we will explore further in the next chapter. As a hint, this pairing involves the lines int main() and return 0;.
Before we jump into creating, compiling, and running this program, we need to get an overview of the whole development process and the tools we'll be using.