Functions deliver values back to the main program by using return values . Here is the program with modifications so that the function returns the wage to the main program. In version 1 of the sample program, the function printed the wage to the screen, but in this version, the wage is not printed in the function but is returned to the main function, and printed there. Summary of the work on functions. There will be more example programs in following topics which will help you to come to grips with these concepts.
Every program has a main function which is where the execution of the program starts and finishes.
The role of the main function is to coordinate the sequence in which the separate functions are called. In general, you should aim to keep the main function less than one page in length. It should read like a logical summary of the solution. Above main are placed the names, return types and parameter lists of all the functions it will call upon. Below main are placed all the function definitions .