Computer Labs homework
C101 Laboratory Session #7
Lab Goals – 1) Learning how to write functions. 2) Writing functions that return information back via the function name. 3) Writing functions that return information back via reference parameters.
Write a program that has user enter three integers, the largest of the three will then be displayed. Use a function that will accept the three integers from the main function and then calculate the maximum of those three and pass it back. You need to do this problem two ways.
The first way is to write a function that returns the maximum value back using a value returning function, that is it uses the word return, with a value, in the function body.
The second way is to write the function so that the largest integer is passed back via a reference parameter, so now the function is a void function.
You need to have two separate programs to do this or you could do it in one program, which ever you find easier. You also must have a loop structure of some kind that allows the user to continue until they press ‘N’ or ‘n’ to stop.
Use an if –else if structure to determine which number is the largest.