When we write a function which accepts input via parameters, processes that information and delivers a result back by returning it then our function behaves like a black box which can be readily reused in any programs which require that processing. In the sample program of topic 9 we used a function which calculated the wage of an employee and and printed this value directly onto the screen. It would better if the function calculated the wage and delivered it back to the main program.
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.