SlideShare a Scribd company logo
1 of 22
1
Advance Computer Programming(3320702)
CH – 3
Functions
GOVERNMENT POLYTECHNIC,
AHMEDABAD
SHAH DHRUV P. (166170307093)
SHAH HARSH J. (166170307095)
SHAH KUNJ D. (166170307096)
SUBMITTED BY
TOPICS
2
• Functions.
• Prototype.
• Nested Functions.
• Types of Functions.
• Recursion.
• Call By Value & Call By Refrence.
• Function & Array.
• Storage Classes.
FUNCTIONS
3
• Defination :- A function is a self contained block of statements
that performs a co-herent task of some kind.
• Every C program can be thought of as a collection of this
function.
• Functions are used when user wants to call a multiple times.
• Functions returns value as either 1 or 0.
• A void function will never return a value.
3.1
PROTOTYPE
4
• Prototype is used when a user wants to define a function after the main()
function.
• The syntax for prototype inside main() function is:-
data_type function_name(data_type1,data_type 2,……data_type n);
3.2
NESTED FUNCTIONS
5
• If a function makes a call to another function in its body , then it
is called Nested Function.
• For example while making a program of sorting an array , user
uses the swap function inside the function of sorting.
3.3
EXAMPLE:-
6
`
void sort (int a[ ],int n)
{ int i,j;
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
if(a[i] > a[j])
{
swap( a[i] , a[j] )
}
}
}
}
TYPES OF FUNCTIONS
7
Function
Library
Functions
User Defined
Functions
3.4
LIBRARY FUNCTIONS
8
• Library Functions are the predefined functions in C language.
• These are the functions which can’t be changed.
• The example of these functions is main().
USER DEFINED FUNCTIONS
9
• User defined Functions are functions which are made by the user
in a C program and called in main() function.
• User defined functions are of 4 types:-
1. No Return value and No Argument.
2. With Return value and No Argument.
3. No Return value and With Argument.
4. With Return value and With Argument.
NO RETURN VALUE AND NO ARGUMENT
10
• Syntax for declaration :-
void Function_name()
{
BODY
}
• Syntax for calling:-
Function_name();
NO RETURN VALUE AND WITH
ARGUMENT
11
• Syntax for declaration :-
void Function_name(argument 1,
argument2…….argument n)
{
BODY
}
• Syntax for calling:-
Function_name(argument 1,argument 2,
……..argument n);
WITH RETURN VALUE AND NO
ARGUMENT
12
• Syntax for declaration :-
data_type Function_name()
{
BODY
}
• Syntax for calling:-
data_type variable_name=Function_name();
WITH RETURN VALUE AND WITH
ARGUMENT
13
• Syntax for declaration :-
data_type variable=
Function_name(argument 1,argument 2……argument n)
{
BODY
}
• Syntax for calling:-
data_type variable_name=Function_name(argument 1,
argument 2……..argument n);
RECURSION
14
• When a function calls itself it is called Recursion.
• Recursion is used in finding factorial of number , Fibonacci
sequence , etc.
• Advantages of recursion are:-
1. Unnecessary use of loop can be stopped.
2. Returning of unnecessary value can be stopped.
3.5
RECURSION
15
• Disadvantages of recursion :-
1. If condition is necessary to return a value.
2. Sometimes it is difficult to trace the flow in recursion.
CALL BY VALUE
16
• While passing the argument in a function if the parameter
passed is the value , it is called call by value.
• For example :- While making a function of swapping , the value
passed as parameter is value of a variable ,it is called call by
value.
3.6
CALL BY REFERENCE
17
• While passing the argument in a function if the parameter
passed is the reference variable i.e. address of variable, it is
called call by reference.
• For example :- While making a function of swapping , the value
passed as parameter is address of a variable ,it is called call by
reference.
FUNCTION & ARRAY
18
• In function user can also pass the array as a parameter .
• When array is passed as a parameter in a function , actually
the address of the first element in array is passed .
• Here , user has to take one more parameter with the array as
the total number of elements in array.
3.7
STORAGE CLASSES
19
3.8
Storage
Classes
Scope of
variables
Life of
variables
SCOPE OF VARIABLES
20
• Scope of Variables can divided into 2 types:-
1. Local Variables.
2. Global Variables.
1. Local Variables:- Scope of local variables is limited upto a
function block (i.e. within the curly braces).
SCOPE OF VARIABLES
21
2. Global Variables :- Global Variables has no such boundary limit .
The Global Variables can be accessed from any where in the C
program
These variables are declared above the main() function.
LIFE OF VARIABLE
22
• The life of local variable is limited upto the curly braces while
the life of Global Variable is till the program termination as it is
declared only once in the program.
• Register Variable :- Register variables are used to execute the
program faster.
• The syntax to declare Register variable is:-
register data_type variable_name;

More Related Content

What's hot

Operator Overloading and Scope of Variable
Operator Overloading and Scope of VariableOperator Overloading and Scope of Variable
Operator Overloading and Scope of VariableMOHIT DADU
 
User Defined Functions in MATLAB Part-4
User Defined Functions in MATLAB Part-4User Defined Functions in MATLAB Part-4
User Defined Functions in MATLAB Part-4Shameer Ahmed Koya
 
Anonymous and Inline Functions in MATLAB
Anonymous and Inline Functions in MATLABAnonymous and Inline Functions in MATLAB
Anonymous and Inline Functions in MATLABShameer Ahmed Koya
 
C programming language working with functions 1
C programming language working with functions 1C programming language working with functions 1
C programming language working with functions 1Jeevan Raj
 
PARAMETER PASSING MECHANISMS
PARAMETER PASSING MECHANISMSPARAMETER PASSING MECHANISMS
PARAMETER PASSING MECHANISMSArpee Callejo
 
Functions in c language
Functions in c language Functions in c language
Functions in c language tanmaymodi4
 
Function in c++
Function in c++Function in c++
Function in c++Kumar
 
Rdbms chapter 1 function
Rdbms chapter 1 functionRdbms chapter 1 function
Rdbms chapter 1 functiondipumaliy
 
Function in C Programming
Function in C ProgrammingFunction in C Programming
Function in C ProgrammingAnil Pokhrel
 
Procedure and Functions in pl/sql
Procedure and Functions in pl/sqlProcedure and Functions in pl/sql
Procedure and Functions in pl/sqlÑirmal Tatiwal
 

What's hot (20)

Operator Overloading and Scope of Variable
Operator Overloading and Scope of VariableOperator Overloading and Scope of Variable
Operator Overloading and Scope of Variable
 
Function and types
Function  and typesFunction  and types
Function and types
 
Parameter passing to_functions_in_c
Parameter passing to_functions_in_cParameter passing to_functions_in_c
Parameter passing to_functions_in_c
 
Functions
FunctionsFunctions
Functions
 
User Defined Functions in MATLAB Part-4
User Defined Functions in MATLAB Part-4User Defined Functions in MATLAB Part-4
User Defined Functions in MATLAB Part-4
 
Anonymous and Inline Functions in MATLAB
Anonymous and Inline Functions in MATLABAnonymous and Inline Functions in MATLAB
Anonymous and Inline Functions in MATLAB
 
Array Cont
Array ContArray Cont
Array Cont
 
C programming language working with functions 1
C programming language working with functions 1C programming language working with functions 1
C programming language working with functions 1
 
Procedure n functions
Procedure n functionsProcedure n functions
Procedure n functions
 
PARAMETER PASSING MECHANISMS
PARAMETER PASSING MECHANISMSPARAMETER PASSING MECHANISMS
PARAMETER PASSING MECHANISMS
 
Storage classess of C progamming
Storage classess of C progamming Storage classess of C progamming
Storage classess of C progamming
 
Functions in c language
Functions in c language Functions in c language
Functions in c language
 
FUNCTION CPU
FUNCTION CPUFUNCTION CPU
FUNCTION CPU
 
Function in c++
Function in c++Function in c++
Function in c++
 
Rdbms chapter 1 function
Rdbms chapter 1 functionRdbms chapter 1 function
Rdbms chapter 1 function
 
3. functions modules_programs (1)
3. functions modules_programs (1)3. functions modules_programs (1)
3. functions modules_programs (1)
 
functions of C++
functions of C++functions of C++
functions of C++
 
Function in C Programming
Function in C ProgrammingFunction in C Programming
Function in C Programming
 
Procedure and Functions in pl/sql
Procedure and Functions in pl/sqlProcedure and Functions in pl/sql
Procedure and Functions in pl/sql
 
LISP:Control Structures In Lisp
LISP:Control Structures In LispLISP:Control Structures In Lisp
LISP:Control Structures In Lisp
 

Similar to Functions in C - Prototypes, recursion, call by value & reference

Similar to Functions in C - Prototypes, recursion, call by value & reference (20)

Functions
FunctionsFunctions
Functions
 
Unit 7. Functions
Unit 7. FunctionsUnit 7. Functions
Unit 7. Functions
 
CH.4FUNCTIONS IN C (1).pptx
CH.4FUNCTIONS IN C (1).pptxCH.4FUNCTIONS IN C (1).pptx
CH.4FUNCTIONS IN C (1).pptx
 
Python functions
Python functionsPython functions
Python functions
 
PSPC-UNIT-4.pdf
PSPC-UNIT-4.pdfPSPC-UNIT-4.pdf
PSPC-UNIT-4.pdf
 
Functions
FunctionsFunctions
Functions
 
Lecture 1_Functions in C.pptx
Lecture 1_Functions in C.pptxLecture 1_Functions in C.pptx
Lecture 1_Functions in C.pptx
 
Function C programming
Function C programmingFunction C programming
Function C programming
 
Chapter One Function.pptx
Chapter One Function.pptxChapter One Function.pptx
Chapter One Function.pptx
 
Functions
FunctionsFunctions
Functions
 
358 33 powerpoint-slides_2-functions_chapter-2
358 33 powerpoint-slides_2-functions_chapter-2358 33 powerpoint-slides_2-functions_chapter-2
358 33 powerpoint-slides_2-functions_chapter-2
 
Functions in c
Functions in cFunctions in c
Functions in c
 
Functions and modular programming.pptx
Functions and modular programming.pptxFunctions and modular programming.pptx
Functions and modular programming.pptx
 
CHAPTER THREE FUNCTION.pptx
CHAPTER THREE FUNCTION.pptxCHAPTER THREE FUNCTION.pptx
CHAPTER THREE FUNCTION.pptx
 
Functions-.pdf
Functions-.pdfFunctions-.pdf
Functions-.pdf
 
Functions in c language
Functions in c languageFunctions in c language
Functions in c language
 
Functions.pptx
Functions.pptxFunctions.pptx
Functions.pptx
 
Functions in c mrs.sowmya jyothi
Functions in c mrs.sowmya jyothiFunctions in c mrs.sowmya jyothi
Functions in c mrs.sowmya jyothi
 
Functions
Functions Functions
Functions
 
1.6 Function.pdf
1.6 Function.pdf1.6 Function.pdf
1.6 Function.pdf
 

Recently uploaded

GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSCAESB
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLDeelipZope
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learningmisbanausheenparvam
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineeringmalavadedarshan25
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerAnamika Sarkar
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.eptoze12
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfAsst.prof M.Gokilavani
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort servicejennyeacort
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxPoojaBan
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...srsj9000
 
Introduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxIntroduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxvipinkmenon1
 

Recently uploaded (20)

GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentation
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCL
 
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learning
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineering
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptx
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
 
Introduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxIntroduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptx
 

Functions in C - Prototypes, recursion, call by value & reference

  • 1. 1 Advance Computer Programming(3320702) CH – 3 Functions GOVERNMENT POLYTECHNIC, AHMEDABAD SHAH DHRUV P. (166170307093) SHAH HARSH J. (166170307095) SHAH KUNJ D. (166170307096) SUBMITTED BY
  • 2. TOPICS 2 • Functions. • Prototype. • Nested Functions. • Types of Functions. • Recursion. • Call By Value & Call By Refrence. • Function & Array. • Storage Classes.
  • 3. FUNCTIONS 3 • Defination :- A function is a self contained block of statements that performs a co-herent task of some kind. • Every C program can be thought of as a collection of this function. • Functions are used when user wants to call a multiple times. • Functions returns value as either 1 or 0. • A void function will never return a value. 3.1
  • 4. PROTOTYPE 4 • Prototype is used when a user wants to define a function after the main() function. • The syntax for prototype inside main() function is:- data_type function_name(data_type1,data_type 2,……data_type n); 3.2
  • 5. NESTED FUNCTIONS 5 • If a function makes a call to another function in its body , then it is called Nested Function. • For example while making a program of sorting an array , user uses the swap function inside the function of sorting. 3.3
  • 6. EXAMPLE:- 6 ` void sort (int a[ ],int n) { int i,j; for(i=0;i<n;i++) { for(j=0;j<n;j++) { if(a[i] > a[j]) { swap( a[i] , a[j] ) } } } }
  • 8. LIBRARY FUNCTIONS 8 • Library Functions are the predefined functions in C language. • These are the functions which can’t be changed. • The example of these functions is main().
  • 9. USER DEFINED FUNCTIONS 9 • User defined Functions are functions which are made by the user in a C program and called in main() function. • User defined functions are of 4 types:- 1. No Return value and No Argument. 2. With Return value and No Argument. 3. No Return value and With Argument. 4. With Return value and With Argument.
  • 10. NO RETURN VALUE AND NO ARGUMENT 10 • Syntax for declaration :- void Function_name() { BODY } • Syntax for calling:- Function_name();
  • 11. NO RETURN VALUE AND WITH ARGUMENT 11 • Syntax for declaration :- void Function_name(argument 1, argument2…….argument n) { BODY } • Syntax for calling:- Function_name(argument 1,argument 2, ……..argument n);
  • 12. WITH RETURN VALUE AND NO ARGUMENT 12 • Syntax for declaration :- data_type Function_name() { BODY } • Syntax for calling:- data_type variable_name=Function_name();
  • 13. WITH RETURN VALUE AND WITH ARGUMENT 13 • Syntax for declaration :- data_type variable= Function_name(argument 1,argument 2……argument n) { BODY } • Syntax for calling:- data_type variable_name=Function_name(argument 1, argument 2……..argument n);
  • 14. RECURSION 14 • When a function calls itself it is called Recursion. • Recursion is used in finding factorial of number , Fibonacci sequence , etc. • Advantages of recursion are:- 1. Unnecessary use of loop can be stopped. 2. Returning of unnecessary value can be stopped. 3.5
  • 15. RECURSION 15 • Disadvantages of recursion :- 1. If condition is necessary to return a value. 2. Sometimes it is difficult to trace the flow in recursion.
  • 16. CALL BY VALUE 16 • While passing the argument in a function if the parameter passed is the value , it is called call by value. • For example :- While making a function of swapping , the value passed as parameter is value of a variable ,it is called call by value. 3.6
  • 17. CALL BY REFERENCE 17 • While passing the argument in a function if the parameter passed is the reference variable i.e. address of variable, it is called call by reference. • For example :- While making a function of swapping , the value passed as parameter is address of a variable ,it is called call by reference.
  • 18. FUNCTION & ARRAY 18 • In function user can also pass the array as a parameter . • When array is passed as a parameter in a function , actually the address of the first element in array is passed . • Here , user has to take one more parameter with the array as the total number of elements in array. 3.7
  • 20. SCOPE OF VARIABLES 20 • Scope of Variables can divided into 2 types:- 1. Local Variables. 2. Global Variables. 1. Local Variables:- Scope of local variables is limited upto a function block (i.e. within the curly braces).
  • 21. SCOPE OF VARIABLES 21 2. Global Variables :- Global Variables has no such boundary limit . The Global Variables can be accessed from any where in the C program These variables are declared above the main() function.
  • 22. LIFE OF VARIABLE 22 • The life of local variable is limited upto the curly braces while the life of Global Variable is till the program termination as it is declared only once in the program. • Register Variable :- Register variables are used to execute the program faster. • The syntax to declare Register variable is:- register data_type variable_name;