C language is a function-based programming language. C program itself is a function. Usually, parameters to the C function are passed as arguments. The function consists of a name followed by the parentheses enclosing arguments or an empty pair of parentheses if there are no arguments required. If there are several arguments, they are separated by commas.
The mandatory part of the C program is the main function. This function must be included in every program because it is the first function run after its execution.
Lets take an example:
#include <stdio.h>
int main(void)
{
printf(“Hello world!\n”);
return 0;
}
This is an elementary C program, but it contains all the necessary elements. Let’s examine a little bit about what we have written here…
#include <stdio.h> – is a preprocessor command. The # sign identifies all preprocessor commands at the beginning of the line. #include command tells the preprocessor to open file stdio.h and from it necessary stored parts while compiling the program. The file name is surrounded by brackets “<>”. Bracket marks“<>” tels the preprocessor to search for the file in the region defined by operating system variables (for instance, “path” variable in Environment variables). If double-quotes are used instead of bracket marks, then file searching is done only in the project’s default directory.
The next line is int main(void). It is always necessary to define the type of function return type, and of course, the function argues. The type int shows that the main function returns an integer, and no arguments to the function are needed.
Opening brace “{” indicates the beginning of the block of sentences. One of those sentences is printf(). This function is taken from stdio.h library and writes a message to the computer terminal (this case screen).
Return 0 is returning parameter to the function. And every function should end with a closing brace “}”.
“/*” is commenting the line. This means that line marked with “/*” is not included in the compilation.