How to make it run

The program in Figure 1 can be executed on a computer. I assume that you have a computer, perhaps a computer looking like the computer in Figure 2.

Figure 2. A computer, of a possible type that you may want to use for programming. It may also be a computer in the form of a mobile phone, or some other device where a computer resides inside.

When you program using the language C you need a compiler. You also need a linker. Often it is possible to obtain a compiler and a linker for free. If Windows is used, it is possible to use Visual C++ 2010 Express. If Linux is used, a compiler by the name of gcc is most likely already available. On Mac OS, an alternative could be to use the Xcode development environment.

The Xcode developent environment for Mac OS includes a version of gcc. This is the case also for an environment called Cygwin, which is available for Windows. This means, in essence, that gcc can be used on Linux, on Mac OS, and on Windows.

Assuming the program in Figure 1 is stored in a file named hello.c, the program can be made to run using gcc. First, the program needs to be compiled. This can be done using the command

gcc -c -Wall hello.c

which takes the file hello.c, and as a result creates a file named hello.o.

The program then needs to be linked, which is done using the command

gcc -o hello hello.o

which takes the file hello.o, and as a result creates an executable program, stored in a file named hello.

The program can then be executed, by giving the command