To get the full benefit of the lesson, watch the video
Lesson 37: Function Parameters & Return value
NOTE: for a fast copy, follow these steps in order:
- Click anywhere in a text box below (result will be a blinking vertical line in the text box)
- Hit ctrl + A on the key board (the "ctrl + A" means hit Ctrl and A at the same time)
(The result should be that all the text inside the text box lights up in blue)
- Hit Ctrl + C (Nothing significantly happens that is visible) and now its copied to the clipboard and your ready to paste it anywhere
you wish
Examples of parameters and return values |
All calculations of any function will use the return value of the function. Here are some examples:
Here are some examples of functions that takes in one parameter x. x does not need to be initialized as a variable in the function x
because it is already initialized as a parameter.
The rules of scope still apply
Here is a function that takes two parameters of the type double
f(double x, z) will NOT be accepted by the C++ compiler
Here is a more complex function taht will take in multiple parameters. Copy and paste this code and change some of the values around to
see what will happen.