5.functions
TRANSCRIPT
Functions
What you’ll learn:
o Introduction to functions
o Passing values to functions
What is a function?
A function is a self-contained block of statement(s)/code that performs a unified task of
some kind.
It is a re-usable code that can be used anywhere and anytime in the whole program.
Syntax of a function
return_type func_name (list_of_arguments);
return_type func_name (list_of_arguments) {
…block of code…
}
func_name(values_of_arguments);
Prototype Declaration:
Definition:
Calling:
Passing Arguments to Functions
int add (int a, int b) {
return a+b;
}
sum = add (i, j);
Formal Arguments
Actual Arguments
• While declaring and defining, formal arguments are used.
• While calling, actual arguments are used.