Please enable JavaScript.
Coggle requires JavaScript to display documents.
5.0 FUNCTION AND
ARRAY - Coggle Diagram
5.0 FUNCTION AND
ARRAY
-
- There are two main parts of the function
-> function header & function body.
-
- In the first line of the above code
-
-
-
-
-
Function Body
-
- Function definitions differ from function declarations in that they supply function bodies.
- What ever is written with in { } in the above example is the body of the function.
-
- A function can be accessed (i.e, called) by specifying its name, followed by a list of arguments enclosed in parentheses and separated by commas.
- In general, subroutines can be passed arguments in one of two ways.
-
-
-
- There are basically two types of functions:
-
-
-
- C allows programmers to define their own functions.
- Is a self-contained program segment that carries out some specific, well-defined task.
-
-
-
- All identifiers in C need to be declared before they are used.
- This is true for functions as well as variables.
- For functions the declaration needs to be before the first call of the function.
- A full declaration includes the return type and the number and type of the arguments.
- Have semicolon “;” at the end of the function.
-
- The return statement terminates the execution of a function and returns control to the calling function.
- When a return statement is executed, the function is terminated immediately at that point, regardless of whether it's in the middle of a loop
- A return statement can also return a value to the calling function.
-
- A return statement without an expression can be used only in functions that do not return a value.
- This prevents their use in any expression and helps avert accidental misuse.
- Before you can use any void function, you must declare its prototype.
- This method copies the value of an argument into the formal parameter of the subroutine.
- In this case, changes made to the parameter have no effect on the argument.
-
- Call by reference is the second way of passing arguments to a subroutine.
- In this method, the address of an argument is copied into the parameter.
-
- A return statement with an expression can be used only in functions returning a value; the value of the expression is returned to the caller of the function.
-