SlideShare a Scribd company logo
1 of 13
Proposed by:-
Lutfullah haqnesar
What is the function?
 Definition: function is self-contained
block of statement that perform a
specific task.
 Function component:
F. declaration
F. definition
F. call
Types of function
 Function is divided into two parts:
 Library functions:- are the parts of header files.
sum(), strcpy(), get().
 User defined :- are provided by
user(programmer).
main().
function
Library
function
User defined
function
Function declaration
 The declaration tells to the computer the
name, return type, parameters of the function.
 The statement is placed after
#include<iostream.h> and before the main()
method.
syntax:
return-type function-name();
or
return-type function-name(argument-list);
example: int sum(int n);
Function definition
 Function definition tells what task the
function will be performing.
 difference between F. definition and F.
declartion is a semicolon ”;” .
 Placed aftre the main().
HEADER// int heading(void)
{
BODY // statement;
}
Function call
 A function only gets life only when it is
called.
 Function call specified by the function
name followed by the arguments
terminated by a semicolon.
 Syntax: <function-name>(argument list); or
variable-name= <function-name>(argument list);
 Example: n=avg(12,6);
Scope of a function
 Local function:
declared inside another function.
can be accessed only inside that function.
 Global function:
declared outside the main() function.
Can be accessed anywhere in the program.
Function over loading
 It is the process of using same name for
two or more function.
 Condition is :should use different types of
parameters.
Inline function
 A function whose code is copied in place of each function
call.
 Declared by prefixing inline keyword to F.call and
F.definition.
Syntax: inline<function-name>()
{
Body of the function
}
Example: Inline int add(int x,int y)
{
Return x+y;
}
Advantages and
disadvantages of inline
Advantages:
1. function calling
not required.
2. executed
faster than
normal function.
Disadvantages:
1. if inline function
are too large
program goes
larger.
2. it makes header
file size larger,may
make it
unreadable.
Program for function
explanation
#include<iostream.h>
Inline double avg(double x, double y); //function declaration.
Int main()
{
Souble a,b;
Cout<<“enter first number:”;
Cin>>a;
Cout<<“enter the second number:”;
Cin>>b;
Cout<<“average is:”<<avg(a,b);// function called.
Return 0;
Inline double avg(double x, double y) // function definition.
{
Return (x+y)/2;
}
Time for you!
Any question ?
Thanks from your support

More Related Content

What's hot

16717 functions in C++
16717 functions in C++16717 functions in C++
16717 functions in C++LPU
 
Call by value
Call by valueCall by value
Call by valueDharani G
 
Functions in c++
Functions in c++Functions in c++
Functions in c++Maaz Hasan
 
Inline function
Inline functionInline function
Inline functionTech_MX
 
Function overloading
Function overloadingFunction overloading
Function overloadingAshish Kelwa
 
C++ overloading
C++ overloadingC++ overloading
C++ overloadingsanya6900
 
Classes function overloading
Classes function overloadingClasses function overloading
Classes function overloadingankush_kumar
 
Function overloading in c++
Function overloading in c++Function overloading in c++
Function overloading in c++Learn By Watch
 
Lecture#6 functions in c++
Lecture#6 functions in c++Lecture#6 functions in c++
Lecture#6 functions in c++NUST Stuff
 
Function overloading(C++)
Function overloading(C++)Function overloading(C++)
Function overloading(C++)Ritika Sharma
 
INLINE FUNCTION IN C++
INLINE FUNCTION IN C++INLINE FUNCTION IN C++
INLINE FUNCTION IN C++Vraj Patel
 
PARAMETER PASSING MECHANISMS
PARAMETER PASSING MECHANISMSPARAMETER PASSING MECHANISMS
PARAMETER PASSING MECHANISMSArpee Callejo
 
C++ Function
C++ FunctionC++ Function
C++ FunctionHajar
 
Inline function(oops)
Inline function(oops)Inline function(oops)
Inline function(oops)Jay Patel
 

What's hot (20)

16717 functions in C++
16717 functions in C++16717 functions in C++
16717 functions in C++
 
Call by value
Call by valueCall by value
Call by value
 
Function overloading
Function overloadingFunction overloading
Function overloading
 
Functions in c++
Functions in c++Functions in c++
Functions in c++
 
Parameter passing to_functions_in_c
Parameter passing to_functions_in_cParameter passing to_functions_in_c
Parameter passing to_functions_in_c
 
Functions in c++
Functions in c++Functions in c++
Functions in c++
 
Functions in C++
Functions in C++Functions in C++
Functions in C++
 
Inline function
Inline functionInline function
Inline function
 
Function overloading
Function overloadingFunction overloading
Function overloading
 
C++ overloading
C++ overloadingC++ overloading
C++ overloading
 
Classes function overloading
Classes function overloadingClasses function overloading
Classes function overloading
 
Function overloading in c++
Function overloading in c++Function overloading in c++
Function overloading in c++
 
Lecture#6 functions in c++
Lecture#6 functions in c++Lecture#6 functions in c++
Lecture#6 functions in c++
 
Function overloading(C++)
Function overloading(C++)Function overloading(C++)
Function overloading(C++)
 
INLINE FUNCTION IN C++
INLINE FUNCTION IN C++INLINE FUNCTION IN C++
INLINE FUNCTION IN C++
 
PARAMETER PASSING MECHANISMS
PARAMETER PASSING MECHANISMSPARAMETER PASSING MECHANISMS
PARAMETER PASSING MECHANISMS
 
C++ Function
C++ FunctionC++ Function
C++ Function
 
Inline function(oops)
Inline function(oops)Inline function(oops)
Inline function(oops)
 
Functions in C++
Functions in C++Functions in C++
Functions in C++
 
C++ functions
C++ functionsC++ functions
C++ functions
 

Similar to Functions Explained in C

POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAAiman Hud
 
D-38 vedant ICCPL.pptx
D-38 vedant ICCPL.pptxD-38 vedant ICCPL.pptx
D-38 vedant ICCPL.pptxVedantSahane
 
functions in c language_functions in c language.pptx
functions in c language_functions in c language.pptxfunctions in c language_functions in c language.pptx
functions in c language_functions in c language.pptxMehakBhatia38
 
unit3 part2 pcds function notes.pdf
unit3 part2 pcds function notes.pdfunit3 part2 pcds function notes.pdf
unit3 part2 pcds function notes.pdfJAVVAJI VENKATA RAO
 
Functions assignment
Functions assignmentFunctions assignment
Functions assignmentAhmad Kamal
 
Operator Overloading and Scope of Variable
Operator Overloading and Scope of VariableOperator Overloading and Scope of Variable
Operator Overloading and Scope of VariableMOHIT DADU
 
VIT351 Software Development VI Unit1
VIT351 Software Development VI Unit1VIT351 Software Development VI Unit1
VIT351 Software Development VI Unit1YOGESH SINGH
 
Module 3-Functions
Module 3-FunctionsModule 3-Functions
Module 3-Functionsnikshaikh786
 
CH.4FUNCTIONS IN C_FYBSC(CS).pptx
CH.4FUNCTIONS IN C_FYBSC(CS).pptxCH.4FUNCTIONS IN C_FYBSC(CS).pptx
CH.4FUNCTIONS IN C_FYBSC(CS).pptxSangeetaBorde3
 
Functions part1
Functions part1Functions part1
Functions part1yndaravind
 
Fnctions part2
Fnctions part2Fnctions part2
Fnctions part2yndaravind
 

Similar to Functions Explained in C (20)

POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
Fp201 unit5 1
Fp201 unit5 1Fp201 unit5 1
Fp201 unit5 1
 
D-38 vedant ICCPL.pptx
D-38 vedant ICCPL.pptxD-38 vedant ICCPL.pptx
D-38 vedant ICCPL.pptx
 
Unit 3 (1)
Unit 3 (1)Unit 3 (1)
Unit 3 (1)
 
functions in c language_functions in c language.pptx
functions in c language_functions in c language.pptxfunctions in c language_functions in c language.pptx
functions in c language_functions in c language.pptx
 
unit3 part2 pcds function notes.pdf
unit3 part2 pcds function notes.pdfunit3 part2 pcds function notes.pdf
unit3 part2 pcds function notes.pdf
 
Function overloading ppt
Function overloading pptFunction overloading ppt
Function overloading ppt
 
Function overloading
Function overloadingFunction overloading
Function overloading
 
Functions assignment
Functions assignmentFunctions assignment
Functions assignment
 
Operator Overloading and Scope of Variable
Operator Overloading and Scope of VariableOperator Overloading and Scope of Variable
Operator Overloading and Scope of Variable
 
VIT351 Software Development VI Unit1
VIT351 Software Development VI Unit1VIT351 Software Development VI Unit1
VIT351 Software Development VI Unit1
 
Function
FunctionFunction
Function
 
Module 3-Functions
Module 3-FunctionsModule 3-Functions
Module 3-Functions
 
Unit-III.pptx
Unit-III.pptxUnit-III.pptx
Unit-III.pptx
 
CH.4FUNCTIONS IN C_FYBSC(CS).pptx
CH.4FUNCTIONS IN C_FYBSC(CS).pptxCH.4FUNCTIONS IN C_FYBSC(CS).pptx
CH.4FUNCTIONS IN C_FYBSC(CS).pptx
 
Functions
Functions Functions
Functions
 
Functions part1
Functions part1Functions part1
Functions part1
 
Fnctions part2
Fnctions part2Fnctions part2
Fnctions part2
 
4. function
4. function4. function
4. function
 
Ch4 functions
Ch4 functionsCh4 functions
Ch4 functions
 

Recently uploaded

Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)Suman Mia
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 
High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...
High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...
High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...Call Girls in Nagpur High Profile
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSRajkumarAkumalla
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxDeepakSakkari2
 
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
 
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
 
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...RajaP95
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Dr.Costas Sachpazis
 
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
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).pptssuser5c9d4b1
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSSIVASHANKAR N
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineeringmalavadedarshan25
 

Recently uploaded (20)

★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 
High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...
High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...
High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptx
 
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
 
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...
 
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
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
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineering
 

Functions Explained in C

  • 2. What is the function?  Definition: function is self-contained block of statement that perform a specific task.  Function component: F. declaration F. definition F. call
  • 3. Types of function  Function is divided into two parts:  Library functions:- are the parts of header files. sum(), strcpy(), get().  User defined :- are provided by user(programmer). main(). function Library function User defined function
  • 4. Function declaration  The declaration tells to the computer the name, return type, parameters of the function.  The statement is placed after #include<iostream.h> and before the main() method. syntax: return-type function-name(); or return-type function-name(argument-list); example: int sum(int n);
  • 5. Function definition  Function definition tells what task the function will be performing.  difference between F. definition and F. declartion is a semicolon ”;” .  Placed aftre the main(). HEADER// int heading(void) { BODY // statement; }
  • 6. Function call  A function only gets life only when it is called.  Function call specified by the function name followed by the arguments terminated by a semicolon.  Syntax: <function-name>(argument list); or variable-name= <function-name>(argument list);  Example: n=avg(12,6);
  • 7. Scope of a function  Local function: declared inside another function. can be accessed only inside that function.  Global function: declared outside the main() function. Can be accessed anywhere in the program.
  • 8. Function over loading  It is the process of using same name for two or more function.  Condition is :should use different types of parameters.
  • 9. Inline function  A function whose code is copied in place of each function call.  Declared by prefixing inline keyword to F.call and F.definition. Syntax: inline<function-name>() { Body of the function } Example: Inline int add(int x,int y) { Return x+y; }
  • 10. Advantages and disadvantages of inline Advantages: 1. function calling not required. 2. executed faster than normal function. Disadvantages: 1. if inline function are too large program goes larger. 2. it makes header file size larger,may make it unreadable.
  • 11. Program for function explanation #include<iostream.h> Inline double avg(double x, double y); //function declaration. Int main() { Souble a,b; Cout<<“enter first number:”; Cin>>a; Cout<<“enter the second number:”; Cin>>b; Cout<<“average is:”<<avg(a,b);// function called. Return 0; Inline double avg(double x, double y) // function definition. { Return (x+y)/2; }
  • 12. Time for you! Any question ?
  • 13. Thanks from your support