


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



General form of a function is: function name (<comma-separated list of parameters>) { statements } Functions are invoked by using the () operator. A function can receive values via parameters. Some functions may not return a value. Some functions may not take any parameters. There are other approaches to define functions.
Let’s define a function that prints a restaurant menu (no parameters). Let’s define a function where the restaurant name is a parameter. Let’s define a function that prints the maximum of two values. Let’s define a function that returns the maximum. Let’s reduce the code of the maximum function. What if we don’t return a value? Let’s add a function that reads the values to compute the maximum. What if we want to compute the maximum of more than two values? Let’s use these examples to practice our testing, debugging techniques.