FUNCTIONS
Now lets incorporate this function into a program.
/* Program illustrating a simple function call */ #include <stdio.h> void print_message( void ); /* ANSI C function prototype */ void print_message( void ) /* the function code */ { printf("This is a module called print_message.\n"); } main() { print_message(); } Sample Program Output This is a module called print_message.
To call a function, it is only necessary to write its name. The code associated with the function name is executed at that point in the program. When the function terminates, execution begins with the statement which follows the function name.
In the above program, execution begins at main(). The only statement inside the main body of the program is a call to the code of function print_message(). This code is executed, and when finished returns back to main().
As there is no further statements inside the main body, the program terminates by returning to the operating system.