That's not a program, that's the source code for a program.
C is a compiled language, meaning it must be "compiled" into machine-readable instructions before you can run it. As you are using C, the "C Compiler" (cc
) can do this.
cc -o fork for.c # compile the code
chmod +x fork # ensure it it executable
./fork # run the compiled program
As you move on to more complicated programs, using multiple source files and external libraries, you'll likely move on to using the "GNU Compiler Collection" (gcc
) and make
to describe how to turn the source code into a working executable.
This questionThis question has various information on the difference between scripts (as you are attempting to treat your source code) and compiled programs.