Basics of functions in C++
Posted On August 11, 2007 by Peter Sebastian Language:
Functions are one of the important ways to decompose software into smaller, manageable chunks. Functions can have return values (for example, a function that computed a value might return that value), or they can return nothing.
If they return nothing, the return type is stated as void and the function is sometimes called a procedure.
In the following example, function f() takes no parameters and returns nothing (that is, its return type is void), and function g() takes two parameters of type int and returns a value of type float.
float g(int x, int y)
float sum = x + y;
float avg = sum / 2.0;
float z = g(2, 3);