Following the main program you will see another program that follows all of the rules set forth so far for a "main" program except that it is named "header()". This is the function which is called from within the main program. Each of these statements are executed, and when they are all complete, control returns to the main program.
The first statement sets the variable "sum" equal to zero because we will use it to accumulate a sum of squares. Since the variable "sum" is defined as an integer type variable prior to the main program, it is available to be used in any of the following functions. It is called a "global" variable, and it’s scope is the entire program and all functions. More will be said about the scope of variables at the end of this chapter. The next statement outputs a header message to the monitor. Program control then returns to the main programs in case there are no additional statements to execute in this function.
It should be clear to you that the two executable lines from this function could be moved to the main program, replacing the header call, and the program would do exactly the same thing that it does as it is now written. This does not minimize the value of functions, it merely illustrates the operation of this simple function is a simple way. You will find functions to be very valuable in C programming
The first statement sets the variable "sum" equal to zero because we will use it to accumulate a sum of squares. Since the variable "sum" is defined as an integer type variable prior to the main program, it is available to be used in any of the following functions. It is called a "global" variable, and it’s scope is the entire program and all functions. More will be said about the scope of variables at the end of this chapter. The next statement outputs a header message to the monitor. Program control then returns to the main programs in case there are no additional statements to execute in this function.
It should be clear to you that the two executable lines from this function could be moved to the main program, replacing the header call, and the program would do exactly the same thing that it does as it is now written. This does not minimize the value of functions, it merely illustrates the operation of this simple function is a simple way. You will find functions to be very valuable in C programming

