IN ORDER TO IMPLEMENT A SET OF RULES / TUTORIALOUTLET DOT COM IN ORDER TOIMPLEMENTASETOFRULES/TUTORIALOUTLET.COM | Page 11

return a value: void functions, and Functions that return a value. You can also write a function with or without parameters: An example of a void function without parameters is provided in figure F1, line 13 to line 17. An example of a void function with parameters is provided in figure F2, line 8 to line 12. Defining and Calling a void Function without Parameters You define a void function without parameters as follows: void <function-name>( ) { <Body-of-the-function> } <function-name> is the name of the function void <function- name>( ) is the function header. It may also be specified as follows: <Body-of-the-function> ©2011 Gilbert Ndjatou void <function-name>( void ) is the body of the function: It consists of one or more statements that are executed each time the function is called. Page 169 You call a void function without parameters by using the following statement: <function-name> ( ); The program in figure F1 illustrates the definition and calls of a void function without parameters. Figure F1 Defining and Calling a void Function without Parameters 1. /*----- Program to compute the area and the perimeter of rectangles ------*/ 2. 3. #include <iostream> 4. using namespace std; 5. 6. double len, // to hold the length of the rectangle 7. width // to hold the width of the rectangle 8. area, // to hold the area 9. peri;