SlideShare ist ein Scribd-Unternehmen logo
1 von 17
C++ FUNCTION  cpplab.pbworks.com
C++ Function  ,[object Object],[object Object],cpplab.pbworks.com
Why We need Function ? ,[object Object],[object Object],[object Object],[object Object],cpplab.pbworks.com
Example   ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],cout<<&quot;result = &quot;<<result; cout<<&quot; try another x =&quot;; cin>>x; result= x*x+2*x-x/3+23; cout<<&quot;result 2 = &quot;<<result; cout<<&quot; try another x =&quot;; cin>>x; result= x*x+2*x-x/3+23; cout<<&quot;result 3 = &quot;<<result; return 0; } cpplab.pbworks.com
[object Object],cpplab.pbworks.com
Example  ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],cout<<&quot;result = &quot;<<result(x); cout<<&quot; try another x =&quot;; cin>>x; cout<<&quot;result 2 = &quot;<<result(x); cout<<&quot; try another x =&quot;; cin>>x; cout<<&quot;result 3 = &quot;<<result(x); return 0; } int result(int y) { return ( y*y+2*y-y/3+23); } cpplab.pbworks.com
Here We Go  ,[object Object],[object Object],cpplab.pbworks.com
What is a Function ? ,[object Object],[object Object],[object Object],[object Object],[object Object],cpplab.pbworks.com
Example   #include <iostream.h> int result (int y); int main () { int x; cout<<&quot; Welcome here &quot;; cout<<&quot; Please Insert value of x to find the answer of this equation :  result=x*x+2*x-x/3+23 x=&quot;; cin>>x; cout<<&quot;result = &quot;<<result(x); cout<<&quot; try another x =&quot;; cin>>x; cout<<&quot;result 2 = &quot;<<result(x); cout<<&quot; try another x =&quot;; cin>>x; cout<<&quot;result 3 = &quot;<<result(x); return 0; } int result(int y) { return ( y*y+2*y-y/3+23); } Function prototype Function  call Function Definition cpplab.pbworks.com
Function Prototype ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],cpplab.pbworks.com
Function Definition  ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],cpplab.pbworks.com
Function Call ,[object Object],[object Object],[object Object],[object Object],[object Object],cpplab.pbworks.com
Example   ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Function prototype Function prototype Function prototype Function call Function  definition  cpplab.pbworks.com
Remmber  .. ,[object Object],[object Object],[object Object],[object Object],[object Object],cpplab.pbworks.com
Return value  ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],double  here means function will return one value with type  double Because the function return  double  value , so we Have to call this function inside  cout staement or assign it to any variable with same type e.g.  double  m=circle (reduis); cpplab.pbworks.com We use ”return ” because the function return value with  type  double
Parameter ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Double r  here means function will pass one parameter form place  of calling with type  double Because the function return  double  value , so we Have to call this function inside  cout staement or assign it to any variable with same type e.g.  double  m=circle (reduis); cpplab.pbworks.com We use ”return ” because the function return value with  type  double
[object Object],[object Object],[object Object],[object Object],[object Object],cpplab.pbworks.com

Weitere ähnliche Inhalte

Was ist angesagt?

Call by value
Call by valueCall by value
Call by value
Dharani G
 

Was ist angesagt? (20)

Function overloading ppt
Function overloading pptFunction overloading ppt
Function overloading ppt
 
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
 
Functions in c
Functions in cFunctions in c
Functions in c
 
Functions in c language
Functions in c language Functions in c language
Functions in c language
 
C string
C stringC string
C string
 
Constructor and destructor
Constructor  and  destructor Constructor  and  destructor
Constructor and destructor
 
Functions in c++
Functions in c++Functions in c++
Functions in c++
 
FUNCTIONS IN c++ PPT
FUNCTIONS IN c++ PPTFUNCTIONS IN c++ PPT
FUNCTIONS IN c++ PPT
 
Functions in C
Functions in CFunctions in C
Functions in C
 
Inline Functions and Default arguments
Inline Functions and Default argumentsInline Functions and Default arguments
Inline Functions and Default arguments
 
classes and objects in C++
classes and objects in C++classes and objects in C++
classes and objects in C++
 
Presentation on Function in C Programming
Presentation on Function in C ProgrammingPresentation on Function in C Programming
Presentation on Function in C Programming
 
virtual function
virtual functionvirtual function
virtual function
 
Function
FunctionFunction
Function
 
C++ classes tutorials
C++ classes tutorialsC++ classes tutorials
C++ classes tutorials
 
Functions in C++
Functions in C++Functions in C++
Functions in C++
 
Functions in C++
Functions in C++Functions in C++
Functions in C++
 
Programming Fundamentals Functions in C and types
Programming Fundamentals  Functions in C  and typesProgramming Fundamentals  Functions in C  and types
Programming Fundamentals Functions in C and types
 
C functions
C functionsC functions
C functions
 

Ähnlich wie C++ Function

Dti2143 chapter 5
Dti2143 chapter 5Dti2143 chapter 5
Dti2143 chapter 5
alish sha
 
function in in thi pdf you will learn what is fu...
function in  in thi pdf you will learn   what                           is fu...function in  in thi pdf you will learn   what                           is fu...
function in in thi pdf you will learn what is fu...
kushwahashivam413
 
Classes function overloading
Classes function overloadingClasses function overloading
Classes function overloading
ankush_kumar
 

Ähnlich wie C++ Function (20)

Chap 5 c++
Chap 5 c++Chap 5 c++
Chap 5 c++
 
Chap 5 c++
Chap 5 c++Chap 5 c++
Chap 5 c++
 
C++ Functions.ppt
C++ Functions.pptC++ Functions.ppt
C++ Functions.ppt
 
overloading in C++
overloading in C++overloading in C++
overloading in C++
 
Functions
FunctionsFunctions
Functions
 
Dti2143 chapter 5
Dti2143 chapter 5Dti2143 chapter 5
Dti2143 chapter 5
 
Function in c
Function in cFunction in c
Function in c
 
Function in c
Function in cFunction in c
Function in c
 
Lecture5
Lecture5Lecture5
Lecture5
 
Operator overloading
Operator overloadingOperator overloading
Operator overloading
 
Unit 4.pdf
Unit 4.pdfUnit 4.pdf
Unit 4.pdf
 
Array Cont
Array ContArray Cont
Array Cont
 
function in in thi pdf you will learn what is fu...
function in  in thi pdf you will learn   what                           is fu...function in  in thi pdf you will learn   what                           is fu...
function in in thi pdf you will learn what is fu...
 
Classes function overloading
Classes function overloadingClasses function overloading
Classes function overloading
 
Function in c program
Function in c programFunction in c program
Function in c program
 
C function
C functionC function
C function
 
Functionincprogram
FunctionincprogramFunctionincprogram
Functionincprogram
 
An imperative study of c
An imperative study of cAn imperative study of c
An imperative study of c
 
C++ Homework Help
C++ Homework HelpC++ Homework Help
C++ Homework Help
 
46630497 fun-pointer-1
46630497 fun-pointer-146630497 fun-pointer-1
46630497 fun-pointer-1
 

Kürzlich hochgeladen

1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
QucHHunhnh
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
negromaestrong
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
heathfieldcps1
 

Kürzlich hochgeladen (20)

INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 

C++ Function

  • 1. C++ FUNCTION cpplab.pbworks.com
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9. Example #include <iostream.h> int result (int y); int main () { int x; cout<<&quot; Welcome here &quot;; cout<<&quot; Please Insert value of x to find the answer of this equation : result=x*x+2*x-x/3+23 x=&quot;; cin>>x; cout<<&quot;result = &quot;<<result(x); cout<<&quot; try another x =&quot;; cin>>x; cout<<&quot;result 2 = &quot;<<result(x); cout<<&quot; try another x =&quot;; cin>>x; cout<<&quot;result 3 = &quot;<<result(x); return 0; } int result(int y) { return ( y*y+2*y-y/3+23); } Function prototype Function call Function Definition cpplab.pbworks.com
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.