Functions
Do you know how to make instant coffee? Don't worry; I know. You will need some water, instant coffee, sugar, and milk or creamer. Remember, we want to drink coffee, but we are doing something that makes coffee. This procedure can be defined as a function of coffee making. Let's finish making coffee now. The steps can be written as follows:
Boil some water.
Put some coffee inside a mug.
Add some sugar.
Pour in boiled water.
Add some milk.
And finally, your coffee is ready! Let's write a pseudo code for this function:
function coffee (water, coffee, sugar, milk) { add coffee beans; add sugar; pour boiled water; add milk; return coffee; }
In our pseudo code we have four items (we would call them parameters) to make coffee. We did something with our ingredients, and finally, we got our coffee, right? Now, if anybody wants to get coffee, he/she will have to do the same function (in programming, we will call it calling a function) again....