SlideShare une entreprise Scribd logo
1  sur  15
Functions
C++ lecture 03
Functions
 Functions allow to structure programs in segments of code to
perform individual tasks.
 It is a group of statements that is given a name, and which can be
called from some point of the program.
 The most common syntax to define a function is:
type name ( parameter1, parameter2, ...)
{
statements
}
 type - the type of the value returned by the
function.
 Name - the identifier by which the function can be
called.
 Parameters -The purpose of parameters is to allow
passing arguments to the function from the location
where it is called from.
 Statements - the function's body. It is a block of
statements surrounded by braces { } that specify
what the function actually does.
Functions
Example
int addition (int a, int b)
{
int r;
r=a+b;
return r;
}
int main () {
int z;
z = addition (5,3);
cout << "The result is " << z;
}
Type
Name
Parameter
Statements
Explanation
 The final statement within the function:
return r;
int subtraction (int a, int b) {
int r;
r=a-b;
return r;
}
int main () {
int x=5, y=3, z;
z = subtraction (7,2);
cout << "The first result is " << z << 'n';
cout << "The second result is " << subtraction
(7,2) << 'n';
cout << "The third result is " << subtraction
(x,y) << 'n';
z= 4 + subtraction (x,y);
cout << "The fourth result is " << z << 'n'; }
Functions with no return type
// void function example
#include <iostream>
using namespace std;
void printmessage () {
cout << "I'm a function!";
}
int main () {
printmessage ();
}
Arguments passed by value
 when calling a function, the values of the arguments on
the moment of the call, which are copied into the variables
represented by the function parameters.
 For example, take:
int x=5, y=3, z;
z = addition ( x, y );
Arguments passed by
reference
 Passing by reference refers to a method of passing
arguments where the value of an argument in the
calling function can be modified in the called
function.
 It allows to access an external variable from within
a function
passing parameters by reference
#include <iostream>
using namespace std;
void duplicate (int& a, int& b, int& c) {
a*=2;
b*=2;
c*=2;
}
int main () {
int x=1, y=3, z=7;
duplicate (x, y, z);
cout << "x=" << x << ", y=" << y << ", z=" << z;
return 0;
}
Explanation
 When a variable is passed by reference, what is passed is no
longer a copy
 the variable itself, identified by the function parameter
associated with the argument passed to the function
 any modification on local variables within the function are
reflected in the variables passed as arguments in the call
Declaration
 If instead of defining duplicate as:
 void duplicate (int& a, int& b, int& c)
 Was it to be defined without the ampersand signs as:
void duplicate (int a, int b, int c)
 The variables would not be passed by reference, but by
value, creating instead copies of their values.
 In this case, the output of the program would have
been the values of x, y, and z without being modified
(i.e., 1, 3, and 7)
Recursive Functions
 Recursive is the property that functions have to be
called by themselves
 n! = n * (n-1) * (n-2) * (n-3) ... * 1
 5! = 5 * 4 * 3 * 2 * 1 = 120
while ( i <= number) {
Factorial = Factorial * i;
++i;
}
Recursive Function
int factorial (int a) {
if (a > 1)
return (a * factorial (a-1));
else
return 1;
}
C++ Standard Library
 Refer the following website and find the C++ standard
header files and inbuilt functions.
 www.cplusplus.com/reference/

Contenu connexe

Tendances (20)

parameter passing in c#
parameter passing in c#parameter passing in c#
parameter passing in c#
 
Recursion in c++
Recursion in c++Recursion in c++
Recursion in c++
 
Function overloading(C++)
Function overloading(C++)Function overloading(C++)
Function overloading(C++)
 
C++ Function
C++ FunctionC++ Function
C++ Function
 
Maharishi University of Management (MSc Computer Science test questions)
Maharishi University of Management (MSc Computer Science test questions)Maharishi University of Management (MSc Computer Science test questions)
Maharishi University of Management (MSc Computer Science test questions)
 
Function in C Language
Function in C Language Function in C Language
Function in C Language
 
Function in c program
Function in c programFunction in c program
Function in c program
 
Function in c language(defination and declaration)
Function in c language(defination and declaration)Function in c language(defination and declaration)
Function in c language(defination and declaration)
 
C function
C functionC function
C function
 
C standard library functions
C standard library functionsC standard library functions
C standard library functions
 
Function & Recursion in C
Function & Recursion in CFunction & Recursion in C
Function & Recursion in C
 
This pointer
This pointerThis pointer
This pointer
 
Function in C program
Function in C programFunction in C program
Function in C program
 
Function in c
Function in cFunction in c
Function in c
 
Function Pointer
Function PointerFunction Pointer
Function Pointer
 
C and C++ functions
C and C++ functionsC and C++ functions
C and C++ functions
 
functions in C
functions in Cfunctions in C
functions in C
 
Function in c
Function in cFunction in c
Function in c
 
03 function overloading
03 function overloading03 function overloading
03 function overloading
 
Working with functions in matlab
Working with functions in matlabWorking with functions in matlab
Working with functions in matlab
 

En vedette

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
 
Functions in c++
Functions in c++Functions in c++
Functions in c++Maaz Hasan
 
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
 
Functions in C++
Functions in C++Functions in C++
Functions in C++home
 
Web Applications Under Attack: Why Network Security Solutions Leave You Exposed
Web Applications Under Attack: Why Network Security Solutions Leave You ExposedWeb Applications Under Attack: Why Network Security Solutions Leave You Exposed
Web Applications Under Attack: Why Network Security Solutions Leave You ExposedImperva
 

En vedette (20)

C++ lecture 04
C++ lecture 04C++ lecture 04
C++ lecture 04
 
C++ lecture 01
C++   lecture 01C++   lecture 01
C++ lecture 01
 
C++ lecture 02
C++   lecture 02C++   lecture 02
C++ lecture 02
 
Lecture 02 networking
Lecture 02 networkingLecture 02 networking
Lecture 02 networking
 
Lecture 01 networking
Lecture 01 networkingLecture 01 networking
Lecture 01 networking
 
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++ مشروع
 
Functions in C++
Functions in C++Functions in C++
Functions in 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
 
Network Security in 2016
Network Security in 2016Network Security in 2016
Network Security in 2016
 
Functions in c++
Functions in c++Functions in c++
Functions in c++
 
Learning C++ - Functions in C++ 3
Learning C++ - Functions  in C++ 3Learning C++ - Functions  in C++ 3
Learning C++ - Functions in C++ 3
 
The Algebra of Functions
The Algebra of FunctionsThe Algebra of Functions
The Algebra of Functions
 
Basic openCV Functions Using CPP
Basic openCV Functions Using CPPBasic openCV Functions Using CPP
Basic openCV Functions Using CPP
 
Functions in C++
Functions in C++Functions in C++
Functions in C++
 
C++ ppt
C++ pptC++ ppt
C++ ppt
 
Web Applications Under Attack: Why Network Security Solutions Leave You Exposed
Web Applications Under Attack: Why Network Security Solutions Leave You ExposedWeb Applications Under Attack: Why Network Security Solutions Leave You Exposed
Web Applications Under Attack: Why Network Security Solutions Leave You Exposed
 
Functions in c++
Functions in c++Functions in c++
Functions in c++
 

Similaire à C++ lecture 03

UNIT3.pptx
UNIT3.pptxUNIT3.pptx
UNIT3.pptxNagasaiT
 
Dti2143 chapter 5
Dti2143 chapter 5Dti2143 chapter 5
Dti2143 chapter 5alish sha
 
C Programming Language Part 7
C Programming Language Part 7C Programming Language Part 7
C Programming Language Part 7Rumman Ansari
 
Amit user defined functions xi (2)
Amit  user defined functions xi (2)Amit  user defined functions xi (2)
Amit user defined functions xi (2)Arpit Meena
 
Unit_5Functionspptx__2022_12_27_10_47_17 (1).pptx
Unit_5Functionspptx__2022_12_27_10_47_17 (1).pptxUnit_5Functionspptx__2022_12_27_10_47_17 (1).pptx
Unit_5Functionspptx__2022_12_27_10_47_17 (1).pptxvekariyakashyap
 
Classes function overloading
Classes function overloadingClasses function overloading
Classes function overloadingankush_kumar
 
C++ FUNCTIONS-1.pptx
C++ FUNCTIONS-1.pptxC++ FUNCTIONS-1.pptx
C++ FUNCTIONS-1.pptxShashiShash2
 
FUNCTIONS IN C PROGRAMMING.pdf
FUNCTIONS IN C PROGRAMMING.pdfFUNCTIONS IN C PROGRAMMING.pdf
FUNCTIONS IN C PROGRAMMING.pdfRITHIKA R S
 
46630497 fun-pointer-1
46630497 fun-pointer-146630497 fun-pointer-1
46630497 fun-pointer-1AmIt Prasad
 

Similaire à C++ lecture 03 (20)

UNIT3.pptx
UNIT3.pptxUNIT3.pptx
UNIT3.pptx
 
Functions
FunctionsFunctions
Functions
 
Dti2143 chapter 5
Dti2143 chapter 5Dti2143 chapter 5
Dti2143 chapter 5
 
Functions
FunctionsFunctions
Functions
 
C Programming Language Part 7
C Programming Language Part 7C Programming Language Part 7
C Programming Language Part 7
 
Amit user defined functions xi (2)
Amit  user defined functions xi (2)Amit  user defined functions xi (2)
Amit user defined functions xi (2)
 
Fp201 unit5 1
Fp201 unit5 1Fp201 unit5 1
Fp201 unit5 1
 
Unit_5Functionspptx__2022_12_27_10_47_17 (1).pptx
Unit_5Functionspptx__2022_12_27_10_47_17 (1).pptxUnit_5Functionspptx__2022_12_27_10_47_17 (1).pptx
Unit_5Functionspptx__2022_12_27_10_47_17 (1).pptx
 
Classes function overloading
Classes function overloadingClasses function overloading
Classes function overloading
 
functions of C++
functions of C++functions of C++
functions of C++
 
C++ FUNCTIONS-1.pptx
C++ FUNCTIONS-1.pptxC++ FUNCTIONS-1.pptx
C++ FUNCTIONS-1.pptx
 
C++ FUNCTIONS-1.pptx
C++ FUNCTIONS-1.pptxC++ FUNCTIONS-1.pptx
C++ FUNCTIONS-1.pptx
 
functions
functionsfunctions
functions
 
Unit 4 (1)
Unit 4 (1)Unit 4 (1)
Unit 4 (1)
 
Lecture 5
Lecture 5Lecture 5
Lecture 5
 
FUNCTIONS IN C PROGRAMMING.pdf
FUNCTIONS IN C PROGRAMMING.pdfFUNCTIONS IN C PROGRAMMING.pdf
FUNCTIONS IN C PROGRAMMING.pdf
 
46630497 fun-pointer-1
46630497 fun-pointer-146630497 fun-pointer-1
46630497 fun-pointer-1
 
Function
FunctionFunction
Function
 
function_v1.ppt
function_v1.pptfunction_v1.ppt
function_v1.ppt
 
function_v1.ppt
function_v1.pptfunction_v1.ppt
function_v1.ppt
 

Dernier

Introduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHIntroduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHC Sai Kiran
 
Comparative Analysis of Text Summarization Techniques
Comparative Analysis of Text Summarization TechniquesComparative Analysis of Text Summarization Techniques
Comparative Analysis of Text Summarization Techniquesugginaramesh
 
Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...121011101441
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxDeepakSakkari2
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...asadnawaz62
 
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)Dr SOUNDIRARAJ N
 
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfCCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfAsst.prof M.Gokilavani
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidNikhilNagaraju
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfAsst.prof M.Gokilavani
 
8251 universal synchronous asynchronous receiver transmitter
8251 universal synchronous asynchronous receiver transmitter8251 universal synchronous asynchronous receiver transmitter
8251 universal synchronous asynchronous receiver transmitterShivangiSharma879191
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfAsst.prof M.Gokilavani
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptSAURABHKUMAR892774
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxbritheesh05
 
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsyncWhy does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsyncssuser2ae721
 
Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfme23b1001
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 
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
 

Dernier (20)

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
 
Introduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHIntroduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECH
 
Comparative Analysis of Text Summarization Techniques
Comparative Analysis of Text Summarization TechniquesComparative Analysis of Text Summarization Techniques
Comparative Analysis of Text Summarization Techniques
 
Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...
 
young call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Serviceyoung call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Service
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptx
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...
 
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
 
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
 
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfCCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfid
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
 
8251 universal synchronous asynchronous receiver transmitter
8251 universal synchronous asynchronous receiver transmitter8251 universal synchronous asynchronous receiver transmitter
8251 universal synchronous asynchronous receiver transmitter
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.ppt
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptx
 
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsyncWhy does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
 
Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdf
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 
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
 

C++ lecture 03

  • 2. Functions  Functions allow to structure programs in segments of code to perform individual tasks.  It is a group of statements that is given a name, and which can be called from some point of the program.  The most common syntax to define a function is: type name ( parameter1, parameter2, ...) { statements }
  • 3.  type - the type of the value returned by the function.  Name - the identifier by which the function can be called.  Parameters -The purpose of parameters is to allow passing arguments to the function from the location where it is called from.  Statements - the function's body. It is a block of statements surrounded by braces { } that specify what the function actually does. Functions
  • 4. Example int addition (int a, int b) { int r; r=a+b; return r; } int main () { int z; z = addition (5,3); cout << "The result is " << z; } Type Name Parameter Statements
  • 5. Explanation  The final statement within the function: return r;
  • 6. int subtraction (int a, int b) { int r; r=a-b; return r; } int main () { int x=5, y=3, z; z = subtraction (7,2); cout << "The first result is " << z << 'n'; cout << "The second result is " << subtraction (7,2) << 'n'; cout << "The third result is " << subtraction (x,y) << 'n'; z= 4 + subtraction (x,y); cout << "The fourth result is " << z << 'n'; }
  • 7. Functions with no return type // void function example #include <iostream> using namespace std; void printmessage () { cout << "I'm a function!"; } int main () { printmessage (); }
  • 8. Arguments passed by value  when calling a function, the values of the arguments on the moment of the call, which are copied into the variables represented by the function parameters.  For example, take: int x=5, y=3, z; z = addition ( x, y );
  • 9. Arguments passed by reference  Passing by reference refers to a method of passing arguments where the value of an argument in the calling function can be modified in the called function.  It allows to access an external variable from within a function
  • 10. passing parameters by reference #include <iostream> using namespace std; void duplicate (int& a, int& b, int& c) { a*=2; b*=2; c*=2; } int main () { int x=1, y=3, z=7; duplicate (x, y, z); cout << "x=" << x << ", y=" << y << ", z=" << z; return 0; }
  • 11. Explanation  When a variable is passed by reference, what is passed is no longer a copy  the variable itself, identified by the function parameter associated with the argument passed to the function  any modification on local variables within the function are reflected in the variables passed as arguments in the call
  • 12. Declaration  If instead of defining duplicate as:  void duplicate (int& a, int& b, int& c)  Was it to be defined without the ampersand signs as: void duplicate (int a, int b, int c)  The variables would not be passed by reference, but by value, creating instead copies of their values.  In this case, the output of the program would have been the values of x, y, and z without being modified (i.e., 1, 3, and 7)
  • 13. Recursive Functions  Recursive is the property that functions have to be called by themselves  n! = n * (n-1) * (n-2) * (n-3) ... * 1  5! = 5 * 4 * 3 * 2 * 1 = 120 while ( i <= number) { Factorial = Factorial * i; ++i; }
  • 14. Recursive Function int factorial (int a) { if (a > 1) return (a * factorial (a-1)); else return 1; }
  • 15. C++ Standard Library  Refer the following website and find the C++ standard header files and inbuilt functions.  www.cplusplus.com/reference/