SlideShare uma empresa Scribd logo
1 de 18
Amity School of Engineering & Technology
1
FUNCTIONS
Presented By:
Shivani Dubey
Priyanka
Yadav
Maaz Hasan
Amity School of Engineering & Technology
CONTENTS• Introduction.
• The Main Function.
• Function Prototyping.
• Call by Reference.
• Return by Reference.
• Inline Function.
• Default Arguments.
• Constant Arguments.
• Recursion.
• Function Overloading.
• Friend and Virtual Function.
• Math Library Function. 2
Amity School of Engineering & Technology
INTRODUCTION
• Divide and conquer :
– Construct a program from smaller pieces or components.
– These smaller pieces are called modules.
– Each piece more manageable than the original program.
– Building blocks of C++.
3
Amity School of Engineering & Technology
• void show(); //function declaration
main()
{
….
show(); //function call
….
}
void show(); //function definition
{
… //function body
…
} 4
AN EXAMPLE
Amity School of Engineering & Technology
THE MAIN FUNCTION
5
• When a program begins running,
the system calls the function main,
which marks the entry point of the
program.
• By default, main has the storage
class extern.
• Every program must have one
function named main, and the
following constraints.
Amity School of Engineering & Technology
FUNCTION PROTOTYPING
• A Function Prototype in C++ is a declaration of
a function that omits the function body but does specify the
function's return type, name and argument types. While a
function definition specifies what a function does, a function
prototype can be thought of as specifying its interface.
6
Amity School of Engineering & Technology
CALL BY REFERENCE
• The Call by Reference method of passing arguments to a
function copies the reference of an argument into the formal
parameter. Inside the function, the reference is used to access
the actual argument used in the call. This means that changes
made to the parameter affect the passed argument.
7
Amity School of Engineering & Technology
AN EXAMPLE
8
#include <iostream>
using namespace std;
// function declaration
void swap(int &x, int &y);
int main ()
{ // local variable declaration:
int a = 100; int b = 200;
cout << "Before swap, value of a :" << a << endl;
cout << "Before swap, value of b :" << b << endl; /* calling a
function to swap the values using variable reference.*/
swap(a, b); cout << "After swap, value of a :" << a << endl;
cout << "After swap, value of b :" << b << endl;
return 0;
}
Amity School of Engineering & Technology
RETURN BY REFERENCE
• A C++ program can be made easier to read and maintain by
using references rather than pointers. A C++ function can
return a reference in a similar way as it returns a pointer.
• When a function returns a reference, it returns an implicit
pointer to its return value. This way, a function can be used on
the left side of an assignment statement.
9
Amity School of Engineering & Technology
INLINE FUNCTION
• An Inline Function the programme
That has requested that the compiler insert
the complete body of the function in
every place that the function is called,
rather than generating code to call the
function in the one place it is defined.
10
Amity School of Engineering & Technology
DEFAULT ARGUEMENTS
• In computer programming, a default argument is an
argument to a function that a programmer is not required to
specify. In most programming languages, functions may take
one or more arguments.
• The default argument must be implicitly convertible to the
parameter type.
11
Amity School of Engineering & Technology
CONSTANT ARGUEMENTS
• The const variable can be declared using const keyword.
• The const keyword makes variable value stable.
• The constant variable should be initialized while declaring.
Syntax:
• (a) const <variable name> = <value>;
• (b) <function name> (const <type>*<variable name>;)
• (c) int const x // in valid
• (d) int const x =5 // valid
12
Amity School of Engineering & Technology
RECURSION
• Recursive functions:
– Functions that call themselves
– Can only solve a base case
– Divide a problem up into
• What it can do.
• What it cannot do.
• What it cannot do resembles
• original problem.
• The function launches a new copy of itself
(recursion step) to solve what it cannot do
13
Amity School of Engineering & Technology
FUNCTION OVERLOADING
• Function overloading is a feature found in that allows
creating several methods with the same name which differ
from each other in the type of the input and the output of the
function. It is simply defined as the ability of one function to
perform different tasks.
14
Amity School of Engineering & Technology
FRIEND & VIRTUAL FUNCTION
15
• A Friend Function access to private and protected data in that
class that it would not normally be able to as if the data was public.
• A Function of global or namespace scope may be declared as friend
of both classes.
• A Virtual Function is a function or method whose behaviour can
be overridden within an inheriting class by a function with the
same signature. This concept is an important part of
the polymorphism portion of Object-Oriented Programming (OOP).
Amity School of Engineering & Technology
MATH LIBRARY FUNCTION
• C Mathematical Operations are a group of functions in
the Standard Library of the C programming
language implementing basic mathematical functions.
16
Amity School of Engineering & Technology
REFERENCES
• Wikipedia.com.
• C++ By Yashwant Kanetkar.
• C++ By E Balagurusamy.
17
Amity School of Engineering & Technology
18

Mais conteúdo relacionado

Mais procurados

Structure of C++ - R.D.Sivakumar
Structure of C++ - R.D.SivakumarStructure of C++ - R.D.Sivakumar
Structure of C++ - R.D.SivakumarSivakumar R D .
 
classes and objects in C++
classes and objects in C++classes and objects in C++
classes and objects in C++HalaiHansaika
 
Inline Functions and Default arguments
Inline Functions and Default argumentsInline Functions and Default arguments
Inline Functions and Default argumentsNikhil Pandit
 
Constructor and Types of Constructors
Constructor and Types of ConstructorsConstructor and Types of Constructors
Constructor and Types of ConstructorsDhrumil Panchal
 
C++ OOPS Concept
C++ OOPS ConceptC++ OOPS Concept
C++ OOPS ConceptBoopathi K
 
Object Oriented Programming Using C++
Object Oriented Programming Using C++Object Oriented Programming Using C++
Object Oriented Programming Using C++Muhammad Waqas
 
RECURSION IN C
RECURSION IN C RECURSION IN C
RECURSION IN C v_jk
 
Virtual function in C++ Pure Virtual Function
Virtual function in C++ Pure Virtual Function Virtual function in C++ Pure Virtual Function
Virtual function in C++ Pure Virtual Function Kamlesh Makvana
 
Operators and expressions in C++
Operators and expressions in C++Operators and expressions in C++
Operators and expressions in C++Neeru Mittal
 
16717 functions in C++
16717 functions in C++16717 functions in C++
16717 functions in C++LPU
 
Inheritance in c++
Inheritance in c++Inheritance in c++
Inheritance in c++Paumil Patel
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in javaTech_MX
 
C Programming: Control Structure
C Programming: Control StructureC Programming: Control Structure
C Programming: Control StructureSokngim Sa
 

Mais procurados (20)

Structure of C++ - R.D.Sivakumar
Structure of C++ - R.D.SivakumarStructure of C++ - R.D.Sivakumar
Structure of C++ - R.D.Sivakumar
 
classes and objects in C++
classes and objects in C++classes and objects in C++
classes and objects in C++
 
Inline Functions and Default arguments
Inline Functions and Default argumentsInline Functions and Default arguments
Inline Functions and Default arguments
 
Function overloading
Function overloadingFunction overloading
Function overloading
 
Constructor and Types of Constructors
Constructor and Types of ConstructorsConstructor and Types of Constructors
Constructor and Types of Constructors
 
Function C programming
Function C programmingFunction C programming
Function C programming
 
C functions
C functionsC functions
C functions
 
C++ OOPS Concept
C++ OOPS ConceptC++ OOPS Concept
C++ OOPS Concept
 
Object Oriented Programming Using C++
Object Oriented Programming Using C++Object Oriented Programming Using C++
Object Oriented Programming Using C++
 
RECURSION IN C
RECURSION IN C RECURSION IN C
RECURSION IN C
 
Virtual function in C++ Pure Virtual Function
Virtual function in C++ Pure Virtual Function Virtual function in C++ Pure Virtual Function
Virtual function in C++ Pure Virtual Function
 
Friend Function
Friend FunctionFriend Function
Friend Function
 
Constructors and Destructor in C++
Constructors and Destructor in C++Constructors and Destructor in C++
Constructors and Destructor in C++
 
Operators and expressions in C++
Operators and expressions in C++Operators and expressions in C++
Operators and expressions in C++
 
Constructors in C++
Constructors in C++Constructors in C++
Constructors in C++
 
16717 functions in C++
16717 functions in C++16717 functions in C++
16717 functions in C++
 
This pointer
This pointerThis pointer
This pointer
 
Inheritance in c++
Inheritance in c++Inheritance in c++
Inheritance in c++
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in java
 
C Programming: Control Structure
C Programming: Control StructureC Programming: Control Structure
C Programming: Control Structure
 

Destaque

Lec 45.46- virtual.functions
Lec 45.46- virtual.functionsLec 45.46- virtual.functions
Lec 45.46- virtual.functionsPrincess Sam
 
Netw450 advanced network security with lab entire class
Netw450 advanced network security with lab entire classNetw450 advanced network security with lab entire class
Netw450 advanced network security with lab entire classEugenioBrown1
 
Functions c++ مشروع
Functions c++ مشروعFunctions c++ مشروع
Functions c++ مشروعziadalmulla
 
Network-security muhibullah aman-first edition-in Persian
Network-security muhibullah aman-first edition-in PersianNetwork-security muhibullah aman-first edition-in Persian
Network-security muhibullah aman-first edition-in PersianMuhibullah Aman
 
Network Security in 2016
Network Security in 2016Network Security in 2016
Network Security in 2016Qrator Labs
 
Learning C++ - Functions in C++ 3
Learning C++ - Functions  in C++ 3Learning C++ - Functions  in C++ 3
Learning C++ - Functions in C++ 3Ali Aminian
 
Basic openCV Functions Using CPP
Basic openCV Functions Using CPPBasic openCV Functions Using CPP
Basic openCV Functions Using CPPWei-Wen Hsu
 
Lec 42.43 - virtual.functions
Lec 42.43 - virtual.functionsLec 42.43 - virtual.functions
Lec 42.43 - virtual.functionsPrincess Sam
 
Functions in C++
Functions in C++Functions in C++
Functions in C++home
 
Functions in C++
Functions in C++Functions in C++
Functions in C++home
 

Destaque (20)

functions of C++
functions of C++functions of C++
functions of C++
 
Functions in C++
Functions in C++Functions in C++
Functions in C++
 
Lec 45.46- virtual.functions
Lec 45.46- virtual.functionsLec 45.46- virtual.functions
Lec 45.46- virtual.functions
 
Inheritance in C++
Inheritance in C++Inheritance in C++
Inheritance in C++
 
Inheritance
InheritanceInheritance
Inheritance
 
OOP C++
OOP C++OOP C++
OOP C++
 
Netw450 advanced network security with lab entire class
Netw450 advanced network security with lab entire classNetw450 advanced network security with lab entire class
Netw450 advanced network security with lab entire class
 
C++ L05-Functions
C++ L05-FunctionsC++ L05-Functions
C++ L05-Functions
 
C++
C++C++
C++
 
Functions c++ مشروع
Functions c++ مشروعFunctions c++ مشروع
Functions c++ مشروع
 
Network-security muhibullah aman-first edition-in Persian
Network-security muhibullah aman-first edition-in PersianNetwork-security muhibullah aman-first edition-in Persian
Network-security muhibullah aman-first edition-in Persian
 
Functions in C++
Functions in C++Functions in C++
Functions in C++
 
Network Security in 2016
Network Security in 2016Network Security in 2016
Network Security in 2016
 
C++ lecture 03
C++   lecture 03C++   lecture 03
C++ lecture 03
 
The Algebra of Functions
The Algebra of FunctionsThe Algebra of Functions
The Algebra of Functions
 
Learning C++ - Functions in C++ 3
Learning C++ - Functions  in C++ 3Learning C++ - Functions  in C++ 3
Learning C++ - Functions in C++ 3
 
Basic openCV Functions Using CPP
Basic openCV Functions Using CPPBasic openCV Functions Using CPP
Basic openCV Functions Using CPP
 
Lec 42.43 - virtual.functions
Lec 42.43 - virtual.functionsLec 42.43 - virtual.functions
Lec 42.43 - virtual.functions
 
Functions in C++
Functions in C++Functions in C++
Functions in C++
 
Functions in C++
Functions in C++Functions in C++
Functions in C++
 

Semelhante a Functions in c++

Chapter One Function.pptx
Chapter One Function.pptxChapter One Function.pptx
Chapter One Function.pptxmiki304759
 
Function different types of funtion
Function different types of funtionFunction different types of funtion
Function different types of funtionsvishalsingh01
 
C++ 2
C++ 2C++ 2
C++ 2jani
 
CHAPTER THREE FUNCTION.pptx
CHAPTER THREE FUNCTION.pptxCHAPTER THREE FUNCTION.pptx
CHAPTER THREE FUNCTION.pptxGebruGetachew2
 
2nd puc computer science chapter 8 function overloading
 2nd puc computer science chapter 8   function overloading 2nd puc computer science chapter 8   function overloading
2nd puc computer science chapter 8 function overloadingAahwini Esware gowda
 
Function Overloading,Inline Function and Recursion in C++ By Faisal Shahzad
Function Overloading,Inline Function and Recursion in C++ By Faisal ShahzadFunction Overloading,Inline Function and Recursion in C++ By Faisal Shahzad
Function Overloading,Inline Function and Recursion in C++ By Faisal ShahzadFaisal Shehzad
 
object oriented programming language.pptx
object oriented programming language.pptxobject oriented programming language.pptx
object oriented programming language.pptxsyedabbas594247
 
Exciting JavaScript - Part I
Exciting JavaScript - Part IExciting JavaScript - Part I
Exciting JavaScript - Part IEugene Lazutkin
 
Polymorphism Using C++
Polymorphism Using C++Polymorphism Using C++
Polymorphism Using C++PRINCE KUMAR
 
Booting into functional programming
Booting into functional programmingBooting into functional programming
Booting into functional programmingDhaval Dalal
 
U19CS101 - PPS Unit 4 PPT (1).ppt
U19CS101 - PPS Unit 4 PPT (1).pptU19CS101 - PPS Unit 4 PPT (1).ppt
U19CS101 - PPS Unit 4 PPT (1).pptManivannan837728
 
OOP-Module-1-Section-4-LectureNo1-5.pptx
OOP-Module-1-Section-4-LectureNo1-5.pptxOOP-Module-1-Section-4-LectureNo1-5.pptx
OOP-Module-1-Section-4-LectureNo1-5.pptxsarthakgithub
 
chapter-8-function-overloading.pdf
chapter-8-function-overloading.pdfchapter-8-function-overloading.pdf
chapter-8-function-overloading.pdfstudy material
 

Semelhante a Functions in c++ (20)

Chapter One Function.pptx
Chapter One Function.pptxChapter One Function.pptx
Chapter One Function.pptx
 
Function overloading
Function overloadingFunction overloading
Function overloading
 
Function different types of funtion
Function different types of funtionFunction different types of funtion
Function different types of funtion
 
C++ 2
C++ 2C++ 2
C++ 2
 
CHAPTER THREE FUNCTION.pptx
CHAPTER THREE FUNCTION.pptxCHAPTER THREE FUNCTION.pptx
CHAPTER THREE FUNCTION.pptx
 
arrays.ppt
arrays.pptarrays.ppt
arrays.ppt
 
Function
Function Function
Function
 
2nd puc computer science chapter 8 function overloading
 2nd puc computer science chapter 8   function overloading 2nd puc computer science chapter 8   function overloading
2nd puc computer science chapter 8 function overloading
 
Function Overloading,Inline Function and Recursion in C++ By Faisal Shahzad
Function Overloading,Inline Function and Recursion in C++ By Faisal ShahzadFunction Overloading,Inline Function and Recursion in C++ By Faisal Shahzad
Function Overloading,Inline Function and Recursion in C++ By Faisal Shahzad
 
object oriented programming language.pptx
object oriented programming language.pptxobject oriented programming language.pptx
object oriented programming language.pptx
 
14 operator overloading
14 operator overloading14 operator overloading
14 operator overloading
 
Exciting JavaScript - Part I
Exciting JavaScript - Part IExciting JavaScript - Part I
Exciting JavaScript - Part I
 
Function overloading
Function overloadingFunction overloading
Function overloading
 
Polymorphism Using C++
Polymorphism Using C++Polymorphism Using C++
Polymorphism Using C++
 
Booting into functional programming
Booting into functional programmingBooting into functional programming
Booting into functional programming
 
Functions
FunctionsFunctions
Functions
 
U19CS101 - PPS Unit 4 PPT (1).ppt
U19CS101 - PPS Unit 4 PPT (1).pptU19CS101 - PPS Unit 4 PPT (1).ppt
U19CS101 - PPS Unit 4 PPT (1).ppt
 
OOP-Module-1-Section-4-LectureNo1-5.pptx
OOP-Module-1-Section-4-LectureNo1-5.pptxOOP-Module-1-Section-4-LectureNo1-5.pptx
OOP-Module-1-Section-4-LectureNo1-5.pptx
 
CPP06 - Functions
CPP06 - FunctionsCPP06 - Functions
CPP06 - Functions
 
chapter-8-function-overloading.pdf
chapter-8-function-overloading.pdfchapter-8-function-overloading.pdf
chapter-8-function-overloading.pdf
 

Mais de Maaz Hasan

Social Media Intelligence
Social Media IntelligenceSocial Media Intelligence
Social Media IntelligenceMaaz Hasan
 
D’ecrivez la Cuisine ou la gastronomies Françoise: Fromage
D’ecrivez la Cuisine ou la gastronomies Françoise: FromageD’ecrivez la Cuisine ou la gastronomies Françoise: Fromage
D’ecrivez la Cuisine ou la gastronomies Françoise: FromageMaaz Hasan
 
Degrading Reading Habits and its Impact on Quality of Education
Degrading Reading Habits and its Impact on Quality of EducationDegrading Reading Habits and its Impact on Quality of Education
Degrading Reading Habits and its Impact on Quality of EducationMaaz Hasan
 
Pattern Recognition
Pattern RecognitionPattern Recognition
Pattern RecognitionMaaz Hasan
 
Population explosion
Population explosionPopulation explosion
Population explosionMaaz Hasan
 
Recent Technology in Data Communication
Recent Technology in Data CommunicationRecent Technology in Data Communication
Recent Technology in Data CommunicationMaaz Hasan
 

Mais de Maaz Hasan (7)

Social Media Intelligence
Social Media IntelligenceSocial Media Intelligence
Social Media Intelligence
 
Quantum dots
Quantum dots Quantum dots
Quantum dots
 
D’ecrivez la Cuisine ou la gastronomies Françoise: Fromage
D’ecrivez la Cuisine ou la gastronomies Françoise: FromageD’ecrivez la Cuisine ou la gastronomies Françoise: Fromage
D’ecrivez la Cuisine ou la gastronomies Françoise: Fromage
 
Degrading Reading Habits and its Impact on Quality of Education
Degrading Reading Habits and its Impact on Quality of EducationDegrading Reading Habits and its Impact on Quality of Education
Degrading Reading Habits and its Impact on Quality of Education
 
Pattern Recognition
Pattern RecognitionPattern Recognition
Pattern Recognition
 
Population explosion
Population explosionPopulation explosion
Population explosion
 
Recent Technology in Data Communication
Recent Technology in Data CommunicationRecent Technology in Data Communication
Recent Technology in Data Communication
 

Último

(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
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations120cr0395
 
(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...
(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...
(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...ranjana rawat
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxupamatechverse
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Call Girls in Nagpur High Profile
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
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
 
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
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Serviceranjana rawat
 
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
 
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
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINESIVASHANKAR N
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
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
 

Último (20)

(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...
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations
 
(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...
(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...
(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptx
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
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
 
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
 
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
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
 
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)
 
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
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
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
 

Functions in c++

  • 1. Amity School of Engineering & Technology 1 FUNCTIONS Presented By: Shivani Dubey Priyanka Yadav Maaz Hasan
  • 2. Amity School of Engineering & Technology CONTENTS• Introduction. • The Main Function. • Function Prototyping. • Call by Reference. • Return by Reference. • Inline Function. • Default Arguments. • Constant Arguments. • Recursion. • Function Overloading. • Friend and Virtual Function. • Math Library Function. 2
  • 3. Amity School of Engineering & Technology INTRODUCTION • Divide and conquer : – Construct a program from smaller pieces or components. – These smaller pieces are called modules. – Each piece more manageable than the original program. – Building blocks of C++. 3
  • 4. Amity School of Engineering & Technology • void show(); //function declaration main() { …. show(); //function call …. } void show(); //function definition { … //function body … } 4 AN EXAMPLE
  • 5. Amity School of Engineering & Technology THE MAIN FUNCTION 5 • When a program begins running, the system calls the function main, which marks the entry point of the program. • By default, main has the storage class extern. • Every program must have one function named main, and the following constraints.
  • 6. Amity School of Engineering & Technology FUNCTION PROTOTYPING • A Function Prototype in C++ is a declaration of a function that omits the function body but does specify the function's return type, name and argument types. While a function definition specifies what a function does, a function prototype can be thought of as specifying its interface. 6
  • 7. Amity School of Engineering & Technology CALL BY REFERENCE • The Call by Reference method of passing arguments to a function copies the reference of an argument into the formal parameter. Inside the function, the reference is used to access the actual argument used in the call. This means that changes made to the parameter affect the passed argument. 7
  • 8. Amity School of Engineering & Technology AN EXAMPLE 8 #include <iostream> using namespace std; // function declaration void swap(int &x, int &y); int main () { // local variable declaration: int a = 100; int b = 200; cout << "Before swap, value of a :" << a << endl; cout << "Before swap, value of b :" << b << endl; /* calling a function to swap the values using variable reference.*/ swap(a, b); cout << "After swap, value of a :" << a << endl; cout << "After swap, value of b :" << b << endl; return 0; }
  • 9. Amity School of Engineering & Technology RETURN BY REFERENCE • A C++ program can be made easier to read and maintain by using references rather than pointers. A C++ function can return a reference in a similar way as it returns a pointer. • When a function returns a reference, it returns an implicit pointer to its return value. This way, a function can be used on the left side of an assignment statement. 9
  • 10. Amity School of Engineering & Technology INLINE FUNCTION • An Inline Function the programme That has requested that the compiler insert the complete body of the function in every place that the function is called, rather than generating code to call the function in the one place it is defined. 10
  • 11. Amity School of Engineering & Technology DEFAULT ARGUEMENTS • In computer programming, a default argument is an argument to a function that a programmer is not required to specify. In most programming languages, functions may take one or more arguments. • The default argument must be implicitly convertible to the parameter type. 11
  • 12. Amity School of Engineering & Technology CONSTANT ARGUEMENTS • The const variable can be declared using const keyword. • The const keyword makes variable value stable. • The constant variable should be initialized while declaring. Syntax: • (a) const <variable name> = <value>; • (b) <function name> (const <type>*<variable name>;) • (c) int const x // in valid • (d) int const x =5 // valid 12
  • 13. Amity School of Engineering & Technology RECURSION • Recursive functions: – Functions that call themselves – Can only solve a base case – Divide a problem up into • What it can do. • What it cannot do. • What it cannot do resembles • original problem. • The function launches a new copy of itself (recursion step) to solve what it cannot do 13
  • 14. Amity School of Engineering & Technology FUNCTION OVERLOADING • Function overloading is a feature found in that allows creating several methods with the same name which differ from each other in the type of the input and the output of the function. It is simply defined as the ability of one function to perform different tasks. 14
  • 15. Amity School of Engineering & Technology FRIEND & VIRTUAL FUNCTION 15 • A Friend Function access to private and protected data in that class that it would not normally be able to as if the data was public. • A Function of global or namespace scope may be declared as friend of both classes. • A Virtual Function is a function or method whose behaviour can be overridden within an inheriting class by a function with the same signature. This concept is an important part of the polymorphism portion of Object-Oriented Programming (OOP).
  • 16. Amity School of Engineering & Technology MATH LIBRARY FUNCTION • C Mathematical Operations are a group of functions in the Standard Library of the C programming language implementing basic mathematical functions. 16
  • 17. Amity School of Engineering & Technology REFERENCES • Wikipedia.com. • C++ By Yashwant Kanetkar. • C++ By E Balagurusamy. 17
  • 18. Amity School of Engineering & Technology 18