User Defined Function
User Defined Function
Sunil Samson 1
USER DEFINED FUNCTION
a program
- will not execute immediately when a page loads
- will be executed by a call to the function
- takes one or more input in the form of parameter
- does some processing using the input and returns a
value.
Called Function:
The Function
which does the job by
receiving the call from
the Calling function
April 24, 2025 A. Sunil Samson 7
ADVANTAGES OF USING FUNCTION
• Code Reusability - defined only once and can be
invoked many times
• Less Code - saves a lot of code because the user
When a problem is
identified, Stating
the information
needed to solve the
Problem
April 24, 2025 A. Sunil Samson 13
DEFINITION OF A FUNCTION
}
- Where return_type => the data type of the value that the function
should return
- Function_name => Name of the function
- Parameter list => Data to be passed to be used by the
function for operation
- April
Function
24, 2025
body => contains a collection of statements that 14
A. Sunil Samson
EXAMPLE: FUNCTION DEFINITION
( CALLED FUNCTION)
int square ( int x ) // function definition
{
int p ;
p=x*x;
return ( p ) ;
}
E
DataType functionName(ParameterList);
Example:
int square ( m ) ;
A repeated
Process, or a
Definiton or a
Procedure
April 24, 2025 A. Sunil Samson 26
WHAT IS RECURSIVE?
- breaking down a problem into smaller and
smaller sub problems
The opportunity or
possibility to do or deal
with something