SlideShare a Scribd company logo
1 of 9
๏‚– By:
๏‚– P.Divya,181602
๏‚– S.sandhiya,181611
๏‚– II B.SC maths [ca]
๏‚– S.B.K.college
๏‚– Aruppukottai
๏‚– TO:
๏‚– K.PADMA PRIYA M.Sc,M.Phil
๏‚– Asst proffesor
๏‚– Dept of maths ca
๏‚– S.B.K.college
๏‚– Arruppukottai
๏‚–
a function is a group of statements that
together perrform a task, function declaration
tells the complier about a functtionโ€™s name ,
return type and parameters.A function
definition provides the actual body of the
function .The c++ standard library provides
numerous built in functions that our program
can call.
๏‚ž Main()function is the entry point of any c++ program.When a c++
program is executed,the execution control goes directly to the main
()function .Every c++ program have a main()function.
๏‚ž main()
๏‚ž {
statements
}
If the main funtion has a return type. The syntax is
int main()
{
โ€ฆโ€ฆโ€ฆ.
โ€ฆโ€ฆโ€ฆ.
return 0;
}
Function prototyping is one very useful feature of
c++ function.Function prototype declaration
statement in the calling program
type function-name(argument-list);
Eg:
float volume (int a,int b,int c)
{
float v=a*b*c;
โ€ฆโ€ฆ.
โ€ฆโ€ฆ.
}
๏‚ž The call by reference method of passing arguments to a function
copies the reference of an argument into the formal prameter.
๏‚ž void swap(int a,int b)
๏‚ž {
๏‚ž int t= a;
๏‚ž a=b;
๏‚ž b=t;
๏‚ž }
๏‚ž Using pointers as follows
๏‚ž void swap(int *a,int*b)
๏‚ž {
๏‚ž t=*a;
๏‚ž *a=*b;
๏‚ž *b=t;
๏‚ž }
A c++ function can return a reference in a similar
way as it returns a pointer .
int & max(int&x,int&y)
{
if(x>y)
return x;
else
return y;
}
๏‚ž Inline fun is a fun which when invoked requests the
compiler to replace the calling statement with its
body.A keyword inline is added before the fun name to
make it inline.
๏‚ž inline function-header
๏‚ž {
๏‚ž function body
๏‚ž }
๏‚ž Eg;
๏‚ž inline double cube(double a)
๏‚ž {
๏‚ž return (a*a*a);
๏‚ž }
๏‚žA default argument is a value provided in a
function declaration that is automatically
assigned by the compiler if the caller of the
function doesnโ€™t provide a value for the
argument with a default value.
๏‚žFunction overloading (also method
overloading )is a programming concept that
allows programmers to define two or more
functions with the same name and in the same
scope .

More Related Content

What's hot

Chapter 5
Chapter 5Chapter 5
Chapter 5
Amrit Kaur
ย 
C++ Function
C++ FunctionC++ Function
C++ Function
Hajar
ย 
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
Jeevan Raj
ย 

What's hot (20)

Functional Programming in JavaScript
Functional Programming in JavaScriptFunctional Programming in JavaScript
Functional Programming in JavaScript
ย 
Function overloading(C++)
Function overloading(C++)Function overloading(C++)
Function overloading(C++)
ย 
Chapter 5
Chapter 5Chapter 5
Chapter 5
ย 
Learning C++ - Functions in C++ 3
Learning C++ - Functions  in C++ 3Learning C++ - Functions  in C++ 3
Learning C++ - Functions in C++ 3
ย 
C++ Function
C++ FunctionC++ Function
C++ Function
ย 
Pointers lesson 5 (double pointer, call by value, call_by_reference)
Pointers lesson 5 (double pointer, call by value, call_by_reference)Pointers lesson 5 (double pointer, call by value, call_by_reference)
Pointers lesson 5 (double pointer, call by value, call_by_reference)
ย 
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
ย 
Lecture#6 functions in c++
Lecture#6 functions in c++Lecture#6 functions in c++
Lecture#6 functions in c++
ย 
Functions in C++ (OOP)
Functions in C++ (OOP)Functions in C++ (OOP)
Functions in C++ (OOP)
ย 
FUNCTIONS IN c++ PPT
FUNCTIONS IN c++ PPTFUNCTIONS IN c++ PPT
FUNCTIONS IN c++ PPT
ย 
Functional programming java
Functional programming javaFunctional programming java
Functional programming java
ย 
Call by value or call by reference in C++
Call by value or call by reference in C++Call by value or call by reference in C++
Call by value or call by reference in C++
ย 
Ankita sharma focp
Ankita sharma focpAnkita sharma focp
Ankita sharma focp
ย 
C++ programming function
C++ programming functionC++ programming function
C++ programming function
ย 
Concept of c
Concept of cConcept of c
Concept of 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++
ย 
03 function overloading
03 function overloading03 function overloading
03 function overloading
ย 
Operator Overloading
Operator OverloadingOperator Overloading
Operator Overloading
ย 
Functional programming 101
Functional programming 101Functional programming 101
Functional programming 101
ย 

Similar to Functions in c++,

functionsinc-130108032745-phpapp01.pdf
functionsinc-130108032745-phpapp01.pdffunctionsinc-130108032745-phpapp01.pdf
functionsinc-130108032745-phpapp01.pdf
mounikanarra3
ย 
Dti2143 chapter 5
Dti2143 chapter 5Dti2143 chapter 5
Dti2143 chapter 5
alish sha
ย 
Recursion in C
Recursion in CRecursion in C
Recursion in C
v_jk
ย 
Function
FunctionFunction
Function
Rajat Patel
ย 
Unit 3 (1)
Unit 3 (1)Unit 3 (1)
Unit 3 (1)
Sowri Rajan
ย 
Function in c
Function in cFunction in c
Function in c
Raj Tandukar
ย 

Similar to Functions in c++, (20)

unit3 part2 pcds function notes.pdf
unit3 part2 pcds function notes.pdfunit3 part2 pcds function notes.pdf
unit3 part2 pcds function notes.pdf
ย 
unit_2.pptx
unit_2.pptxunit_2.pptx
unit_2.pptx
ย 
Function
FunctionFunction
Function
ย 
Functions in c++
Functions in c++Functions in c++
Functions in c++
ย 
Unit 4.pdf
Unit 4.pdfUnit 4.pdf
Unit 4.pdf
ย 
functionsinc-130108032745-phpapp01.pdf
functionsinc-130108032745-phpapp01.pdffunctionsinc-130108032745-phpapp01.pdf
functionsinc-130108032745-phpapp01.pdf
ย 
Functions
FunctionsFunctions
Functions
ย 
unit_2 (1).pptx
unit_2 (1).pptxunit_2 (1).pptx
unit_2 (1).pptx
ย 
Functions
Functions Functions
Functions
ย 
FUNCTIONS IN C PROGRAMMING.pdf
FUNCTIONS IN C PROGRAMMING.pdfFUNCTIONS IN C PROGRAMMING.pdf
FUNCTIONS IN C PROGRAMMING.pdf
ย 
Module 3-Functions
Module 3-FunctionsModule 3-Functions
Module 3-Functions
ย 
Dti2143 chapter 5
Dti2143 chapter 5Dti2143 chapter 5
Dti2143 chapter 5
ย 
Unit-III.pptx
Unit-III.pptxUnit-III.pptx
Unit-III.pptx
ย 
RECURSION IN C
RECURSION IN C RECURSION IN C
RECURSION IN C
ย 
Recursion in C
Recursion in CRecursion in C
Recursion in C
ย 
Chap 5 c++
Chap 5 c++Chap 5 c++
Chap 5 c++
ย 
Function
FunctionFunction
Function
ย 
Unit 3 (1)
Unit 3 (1)Unit 3 (1)
Unit 3 (1)
ย 
Function in c
Function in cFunction in c
Function in c
ย 
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
ย 

More from Padma Kannan (13)

B tree
B treeB tree
B tree
ย 
Operators in C++
Operators in C++Operators in C++
Operators in C++
ย 
Java packags
Java packagsJava packags
Java packags
ย 
Java and c++
Java and c++Java and c++
Java and c++
ย 
Inheritance
InheritanceInheritance
Inheritance
ย 
Functions of dbms
Functions  of dbmsFunctions  of dbms
Functions of dbms
ย 
Classes,object and methods java
Classes,object and methods javaClasses,object and methods java
Classes,object and methods java
ย 
Classes,object and methods jav
Classes,object and methods javClasses,object and methods jav
Classes,object and methods jav
ย 
Basic concept of oops
Basic concept of oopsBasic concept of oops
Basic concept of oops
ย 
LEARNING BASES OF ACTICITY
LEARNING BASES OF ACTICITYLEARNING BASES OF ACTICITY
LEARNING BASES OF ACTICITY
ย 
Social networking risks
Social networking risksSocial networking risks
Social networking risks
ย 
Inheritance
InheritanceInheritance
Inheritance
ย 
Excel2002
Excel2002Excel2002
Excel2002
ย 

Recently uploaded

Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
bodapatigopi8531
ย 
CHEAP Call Girls in Pushp Vihar (-DELHI )๐Ÿ” 9953056974๐Ÿ”(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )๐Ÿ” 9953056974๐Ÿ”(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )๐Ÿ” 9953056974๐Ÿ”(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )๐Ÿ” 9953056974๐Ÿ”(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
ย 
CALL ON โžฅ8923113531 ๐Ÿ”Call Girls Badshah Nagar Lucknow best Female service
CALL ON โžฅ8923113531 ๐Ÿ”Call Girls Badshah Nagar Lucknow best Female serviceCALL ON โžฅ8923113531 ๐Ÿ”Call Girls Badshah Nagar Lucknow best Female service
CALL ON โžฅ8923113531 ๐Ÿ”Call Girls Badshah Nagar Lucknow best Female service
anilsa9823
ย 
CALL ON โžฅ8923113531 ๐Ÿ”Call Girls Kakori Lucknow best sexual service Online โ˜‚๏ธ
CALL ON โžฅ8923113531 ๐Ÿ”Call Girls Kakori Lucknow best sexual service Online  โ˜‚๏ธCALL ON โžฅ8923113531 ๐Ÿ”Call Girls Kakori Lucknow best sexual service Online  โ˜‚๏ธ
CALL ON โžฅ8923113531 ๐Ÿ”Call Girls Kakori Lucknow best sexual service Online โ˜‚๏ธ
anilsa9823
ย 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
ย 

Recently uploaded (20)

How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
ย 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
ย 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
ย 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
ย 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
ย 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
ย 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
ย 
CHEAP Call Girls in Pushp Vihar (-DELHI )๐Ÿ” 9953056974๐Ÿ”(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )๐Ÿ” 9953056974๐Ÿ”(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )๐Ÿ” 9953056974๐Ÿ”(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )๐Ÿ” 9953056974๐Ÿ”(=)/CALL GIRLS SERVICE
ย 
CALL ON โžฅ8923113531 ๐Ÿ”Call Girls Badshah Nagar Lucknow best Female service
CALL ON โžฅ8923113531 ๐Ÿ”Call Girls Badshah Nagar Lucknow best Female serviceCALL ON โžฅ8923113531 ๐Ÿ”Call Girls Badshah Nagar Lucknow best Female service
CALL ON โžฅ8923113531 ๐Ÿ”Call Girls Badshah Nagar Lucknow best Female service
ย 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
ย 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
ย 
CALL ON โžฅ8923113531 ๐Ÿ”Call Girls Kakori Lucknow best sexual service Online โ˜‚๏ธ
CALL ON โžฅ8923113531 ๐Ÿ”Call Girls Kakori Lucknow best sexual service Online  โ˜‚๏ธCALL ON โžฅ8923113531 ๐Ÿ”Call Girls Kakori Lucknow best sexual service Online  โ˜‚๏ธ
CALL ON โžฅ8923113531 ๐Ÿ”Call Girls Kakori Lucknow best sexual service Online โ˜‚๏ธ
ย 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
ย 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
ย 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
ย 
Vip Call Girls Noida โžก๏ธ Delhi โžก๏ธ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida โžก๏ธ Delhi โžก๏ธ 9999965857 No Advance 24HRS LiveVip Call Girls Noida โžก๏ธ Delhi โžก๏ธ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida โžก๏ธ Delhi โžก๏ธ 9999965857 No Advance 24HRS Live
ย 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
ย 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlanโ€™s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlanโ€™s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlanโ€™s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlanโ€™s ...
ย 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
ย 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
ย 

Functions in c++,

  • 1. ๏‚– By: ๏‚– P.Divya,181602 ๏‚– S.sandhiya,181611 ๏‚– II B.SC maths [ca] ๏‚– S.B.K.college ๏‚– Aruppukottai ๏‚– TO: ๏‚– K.PADMA PRIYA M.Sc,M.Phil ๏‚– Asst proffesor ๏‚– Dept of maths ca ๏‚– S.B.K.college ๏‚– Arruppukottai ๏‚–
  • 2. a function is a group of statements that together perrform a task, function declaration tells the complier about a functtionโ€™s name , return type and parameters.A function definition provides the actual body of the function .The c++ standard library provides numerous built in functions that our program can call.
  • 3. ๏‚ž Main()function is the entry point of any c++ program.When a c++ program is executed,the execution control goes directly to the main ()function .Every c++ program have a main()function. ๏‚ž main() ๏‚ž { statements } If the main funtion has a return type. The syntax is int main() { โ€ฆโ€ฆโ€ฆ. โ€ฆโ€ฆโ€ฆ. return 0; }
  • 4. Function prototyping is one very useful feature of c++ function.Function prototype declaration statement in the calling program type function-name(argument-list); Eg: float volume (int a,int b,int c) { float v=a*b*c; โ€ฆโ€ฆ. โ€ฆโ€ฆ. }
  • 5. ๏‚ž The call by reference method of passing arguments to a function copies the reference of an argument into the formal prameter. ๏‚ž void swap(int a,int b) ๏‚ž { ๏‚ž int t= a; ๏‚ž a=b; ๏‚ž b=t; ๏‚ž } ๏‚ž Using pointers as follows ๏‚ž void swap(int *a,int*b) ๏‚ž { ๏‚ž t=*a; ๏‚ž *a=*b; ๏‚ž *b=t; ๏‚ž }
  • 6. A c++ function can return a reference in a similar way as it returns a pointer . int & max(int&x,int&y) { if(x>y) return x; else return y; }
  • 7. ๏‚ž Inline fun is a fun which when invoked requests the compiler to replace the calling statement with its body.A keyword inline is added before the fun name to make it inline. ๏‚ž inline function-header ๏‚ž { ๏‚ž function body ๏‚ž } ๏‚ž Eg; ๏‚ž inline double cube(double a) ๏‚ž { ๏‚ž return (a*a*a); ๏‚ž }
  • 8. ๏‚žA default argument is a value provided in a function declaration that is automatically assigned by the compiler if the caller of the function doesnโ€™t provide a value for the argument with a default value.
  • 9. ๏‚žFunction overloading (also method overloading )is a programming concept that allows programmers to define two or more functions with the same name and in the same scope .