Section 12.2 Multiple Functions
It is possible (and quite normal) to have multiple functions in your C code! By splitting up your code into functions, debugging can become much easier, your code will be more readable, it will be easier for you to remember what you had in mind, ... but more on that later. For now, let’s take a look at an example that involves multiple functions:
If you cannot see this codecast, please click here.
Check Your Understanding Check Your Understanding
2.
Given the following function definition, which is the correct function call, given that a variable
a
of type int
has been declared?
int myaddition(int x, int y)
{
return(x+y);
}
Feel free to use the window below to try out some code. Be sure to work the correct answer out "by hand" first before verifying your answer using the code window.
a = myaddition(3,5);
- Correct
a = myaddition(3,5)
- Not quite. Try again!
int a = myaddition(3,5)
- Not quite. Try again!
a = myaddition(3.0,5.0);
- Not quite. Try again!