SlideShare ist ein Scribd-Unternehmen logo
1 von 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

Weitere ähnliche Inhalte

Was ist angesagt?

Function overloading and overriding
Function overloading and overridingFunction overloading and overriding
Function overloading and overridingRajab Ali
 
Basic Data Types in C++
Basic Data Types in C++ Basic Data Types in C++
Basic Data Types in C++ Hridoy Bepari
 
C++ decision making
C++ decision makingC++ decision making
C++ decision makingZohaib Ahmed
 
Control structures in c++
Control structures in c++Control structures in c++
Control structures in c++Nitin Jawla
 
Polymorphism in c++(ppt)
Polymorphism in c++(ppt)Polymorphism in c++(ppt)
Polymorphism in c++(ppt)Sanjit Shaw
 
Polymorphism Using C++
Polymorphism Using C++Polymorphism Using C++
Polymorphism Using C++PRINCE KUMAR
 
Inheritance in c++
Inheritance in c++Inheritance in c++
Inheritance in c++Paumil Patel
 
Control Statements in Java
Control Statements in JavaControl Statements in Java
Control Statements in JavaNiloy Saha
 
FUNCTIONS IN c++ PPT
FUNCTIONS IN c++ PPTFUNCTIONS IN c++ PPT
FUNCTIONS IN c++ PPT03062679929
 
Java conditional statements
Java conditional statementsJava conditional statements
Java conditional statementsKuppusamy P
 
Operator Overloading
Operator OverloadingOperator Overloading
Operator OverloadingNilesh Dalvi
 
C++ Function
C++ FunctionC++ Function
C++ FunctionHajar
 
Oop c++class(final).ppt
Oop c++class(final).pptOop c++class(final).ppt
Oop c++class(final).pptAlok Kumar
 

Was ist angesagt? (20)

Function overloading and overriding
Function overloading and overridingFunction overloading and overriding
Function overloading and overriding
 
Basic Data Types in C++
Basic Data Types in C++ Basic Data Types in C++
Basic Data Types in C++
 
C++ decision making
C++ decision makingC++ decision making
C++ decision making
 
Functions in C++
Functions in C++Functions in C++
Functions in C++
 
Control structures in c++
Control structures in c++Control structures in c++
Control structures in c++
 
Polymorphism in c++(ppt)
Polymorphism in c++(ppt)Polymorphism in c++(ppt)
Polymorphism in c++(ppt)
 
Polymorphism Using C++
Polymorphism Using C++Polymorphism Using C++
Polymorphism Using C++
 
Inheritance in c++
Inheritance in c++Inheritance in c++
Inheritance in c++
 
Python Functions
Python   FunctionsPython   Functions
Python Functions
 
Structure of a C program
Structure of a C programStructure of a C program
Structure of a C program
 
Constructor
ConstructorConstructor
Constructor
 
Pointer in C++
Pointer in C++Pointer in C++
Pointer in C++
 
Introduction to c++ ppt
Introduction to c++ pptIntroduction to c++ ppt
Introduction to c++ ppt
 
Control Statements in Java
Control Statements in JavaControl Statements in Java
Control Statements in Java
 
FUNCTIONS IN c++ PPT
FUNCTIONS IN c++ PPTFUNCTIONS IN c++ PPT
FUNCTIONS IN c++ PPT
 
Control statements in c
Control statements in cControl statements in c
Control statements in c
 
Java conditional statements
Java conditional statementsJava conditional statements
Java conditional statements
 
Operator Overloading
Operator OverloadingOperator Overloading
Operator Overloading
 
C++ Function
C++ FunctionC++ Function
C++ Function
 
Oop c++class(final).ppt
Oop c++class(final).pptOop c++class(final).ppt
Oop c++class(final).ppt
 

Andere mochten auch

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
 

Andere mochten auch (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++
 

Ähnlich wie 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
 
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
 
Functions in C.pptx
Functions in C.pptxFunctions in C.pptx
Functions in C.pptxAshwini Raut
 

Ähnlich wie 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
 
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
 
Functions in C.pptx
Functions in C.pptxFunctions in C.pptx
Functions in C.pptx
 

Mehr von 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
 

Mehr von 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
 

Kürzlich hochgeladen

chapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringchapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringmulugeta48
 
Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01KreezheaRecto
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college projectTonystark477637
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSISrknatarajan
 
UNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICS
UNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICSUNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICS
UNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICSrknatarajan
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlysanyuktamishra911
 
Glass Ceramics: Processing and Properties
Glass Ceramics: Processing and PropertiesGlass Ceramics: Processing and Properties
Glass Ceramics: Processing and PropertiesPrabhanshu Chaturvedi
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfJiananWang21
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingrknatarajan
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdfankushspencer015
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxAsutosh Ranjan
 
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank  Design by Working Stress - IS Method.pdfIntze Overhead Water Tank  Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank Design by Working Stress - IS Method.pdfSuman Jyoti
 
Vivazz, Mieres Social Housing Design Spain
Vivazz, Mieres Social Housing Design SpainVivazz, Mieres Social Housing Design Spain
Vivazz, Mieres Social Housing Design Spaintimesproduction05
 
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Bookingroncy bisnoi
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...Call Girls in Nagpur High Profile
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Bookingdharasingh5698
 

Kürzlich hochgeladen (20)

(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
 
chapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringchapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineering
 
Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college project
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSIS
 
UNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICS
UNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICSUNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICS
UNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICS
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
 
Glass Ceramics: Processing and Properties
Glass Ceramics: Processing and PropertiesGlass Ceramics: Processing and Properties
Glass Ceramics: Processing and Properties
 
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank  Design by Working Stress - IS Method.pdfIntze Overhead Water Tank  Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
 
Vivazz, Mieres Social Housing Design Spain
Vivazz, Mieres Social Housing Design SpainVivazz, Mieres Social Housing Design Spain
Vivazz, Mieres Social Housing Design Spain
 
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
 
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
 

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