SlideShare a Scribd company logo
2
Most read
8
Most read
10
Most read
BIRLA INSTITUTE OF TECHNOLOGY MESRA,
JAIPUR CAMPUS
:- TARUN TIWARI(MCA/25007/18)
:- NIKHIL AGRAWAL(MCA/25004/18)
TOPIC:- REFERENCE PARAMETERS ,Passing object by reference ,
CONSTANT PARAMETERS & DEFAULT PARAMETER
REFERENCE PARAMETERS &
CONSTANT PARAMETERS
TARUN TIWARI
REFERENCE PARAMETERS
• In call by reference method the called function does not create its own copy rather it
refers to original value only by different name i.e. reference.
• When function is called by reference then, the formal parameter become
reference or alias to the actual parameter in calling function.
• To have a function with multiple outputs, we have to use pass by
reference.
• We use &to denote a parameter that is passed by reference:
Syntax:
<type>& <variable>
Examples:
• void Increment(int& Number);
• void SumAve (double, double, double&, double&);
• The corresponding argument must be a variable.
Increment(Inc);
SumAve(2.5, y+3, sum, mean);
Example of Call By Reference
#include <iostream.h>
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;
}
x=2, y=6, z=14
Void duplicate (int& a, int& b, int& c)
x y z
duplicate( x , y , z )
Advantages of reference parameters
• We can return multiple values from a function
• Because a copy of the argument is not made, it is fast, even when
used with large structs or classes.
• Reference must be initialized
Disadvantages of reference parameters
• Many potential scenarios can occur
• Programs are difficult to understand sometimes
• Un-wanted Aliases
• The const modifier can be applied to formal parameter declarations
• The constant parameter received by the function can not be changed
in the body of the function.
CONSTANT PARAMETERS
• const indicates that the function may not modify the parameter
const type parameter
DECLARATION OF CONSTANT PARAMETERS
return_type FunName(const type1 parameter1, const
type2 parameter2, ..., const typeN parameterN)
{
...
}
EXAMPLE OF CONSTANT PARAMETERS
double Area( const double radius)
{
return double (3.1415 * radius * radius);
}
double area;
area = Area(5.5); area = 95.0304
double r = 7.88;
area = Area(r); area = 195.07
• If you try to change the value of the radius constant in the Area()
function, for example
radius = 2.88;
• the compiler will generate an error:
'radius': you cannot assign to a variable that is const.
PASSING OBJECTS BY
REFERENCE &
DEFAULT PARAMETERS.
NIKHIL AGRAWAL
PASSING OBJECT BY
REFERENCE
 One situation where it is absolutely mandatory to use a reference parameter is when we
pass a Stream object to a function.
 The reason is, When we extract data from a stream or insert data into a stream ,we are
changing the stream.
 As we know, if we passed the stream object by value, any changes that we made to the
stream object would be made to a copy of the stream object, not to the actual object.
 Thus whenever we need to pass a stream to a function, we must pass the stream by
reference.
Example :The following function writes an integer value to a stream
that is passed as the parameter to the function :-
Void OutputValue(ostream &out, int value){
out <<“ Value is “<< Value<<endl;
return;
}
The next line of code uses the OutputValue() to write the value k to
the stream cout :-
OutputValue(cout,k);
• Functions that output values to a stream are
useful when we need to output several values along
with labelling information from several places in a
program.
• We might use such a function to write data to the
display as well as to a log file for later examination.
• Another use would be to help debug the program.
 Example : Suppose , for example, that we wish to “watch” Sort3() function as it sorts the values :-
Void ShowValues(ostream &out , int a, int b, int c) {
Out <<“a: “<<a<<endl;
Out<<“b: “<<b<<endl;
Out<<“c: “<<c<<endl;
return;
}
//sort three numbers into ascending order
Void Sort3(int &a, int &b, int &c) {
If(a>b)
swap(a,b);
ShowValues(clog, a, b, c);
If(a>c)
swap(a,c);
ShowValues(clog, a, b, c);
If(b>c)
swap(b,c);
ShowValues(clog, a, b, c);
 We can also put the ability to pass an input stream as a parameter to a function to good
use.
 For example :
• Suppose we are writing a program to process data from a file.
• Program development and testing will go faster if the program takes the input from the keyboard.
• We can quickly test the program by typing in data, rather than creating a test file each time we
want to test the program on different data.
• However ,eventually the program will be reading data from a file.
• We do not want to write the program so that it accepts input from the keyboard and then , when the
program is complete , have to make extensive changes to the program so that it operates on a
different stream.
• We can handle this situation by writing any functions that extract input to accept as a parameter
the stream to read data from .
Program :
bool ReadValues (istream &in, int &v1, int &v2, int &v3)
{
if ( in == cin)
cout<<“ Please enter three numbers”;
if ( in >> v1 >> v2 >> v3)
return true;
else
return false;
}
DEFAULT ARGUMENTS
 A default argument is a value provided in function declaration that is automatically
assigned by the compiler if caller of the function doesn’t provide a value for the argument
with default value.
 Syntax: f _type f_name (arg1,arg2,arg3=value).
 When a default argument is placed then all the other arguments after that must be
default arguments only.
DEFAULT ARGUMENTS (EXAMPLE)
int sum(int x,int y,int z=0,int w=0)
{
return(x+y+z+w);
}
int main()
{
cout<<sum(10,15)<<endl;
cout<<sum(10,15,25)<<endl;
cout<<sum(10,15,25,30)<<endl;
return 0;
}
• OUTPUT:
25
50
80
DEFAULT ARGUMENTS
 Default arguments are overwritten when calling function provides values for them. For
example, calling of function sum(10, 15, 25, 30) overwrites the value of z and w to 25 and
30 respectively.
 During calling of function, arguments from calling function to called function are copied
from left to right. Therefore, sum(10, 15, 25) will assign 10, 15 and 25 to x, y and z.
Therefore, default value is used for w only.
DEFAULT ARGUMENTS
The default parameter method is especially useful
when one wants to set default criteria so that the
function can be called with or without parameters.
Default arguments are different from constant
arguments as constant arguments can’t be changed
whereas default arguments can be overwritten if
required.
THANK YOU.

More Related Content

PPTX
C# lecture 1: Introduction to Dot Net Framework
Dr.Neeraj Kumar Pandey
 
PPT
Pin diagram of 8085
ShivamSood22
 
PPT
Introduction to intel 8086 part1
Shehrevar Davierwala
 
PDF
C Programming - Refresher - Part I
Emertxe Information Technologies Pvt Ltd
 
PPT
Microprocessor
aaina_katyal
 
PDF
Unit II Arm 7 Introduction
Dr. Pankaj Zope
 
PDF
Addressing modes of 8085 by Er. Swapnil V. Kaware
Prof. Swapnil V. Kaware
 
C# lecture 1: Introduction to Dot Net Framework
Dr.Neeraj Kumar Pandey
 
Pin diagram of 8085
ShivamSood22
 
Introduction to intel 8086 part1
Shehrevar Davierwala
 
C Programming - Refresher - Part I
Emertxe Information Technologies Pvt Ltd
 
Microprocessor
aaina_katyal
 
Unit II Arm 7 Introduction
Dr. Pankaj Zope
 
Addressing modes of 8085 by Er. Swapnil V. Kaware
Prof. Swapnil V. Kaware
 

What's hot (20)

PDF
Embedded C - Lecture 4
Mohamed Abdallah
 
PPT
Microchip's PIC Micro Controller
Midhu S V Unnithan
 
PDF
Introduction to Embedded Systems a Practical Approach
Amr Ali (ISTQB CTAL Full, CSM, ITIL Foundation)
 
PPTX
Addressing modes
Asif Iqbal
 
PDF
Question Bank Microprocessor 8085
Nilesh Bhaskarrao Bahadure
 
PDF
C Programming - Refresher - Part II
Emertxe Information Technologies Pvt Ltd
 
PPTX
Programming with arduino
Makers of India
 
PPTX
Compiler vs Interpreter-Compiler design ppt.
Md Hossen
 
PPTX
Introduction with Programming Language
Saroar Zahan Sojib
 
PDF
8086 MICROPROCESSOR
Akhila Rahul
 
PPTX
C basics
thirumalaikumar3
 
PPT
8051 Addressing Modes
Senthil Kumar
 
PPS
What is Arduino ?
Niket Chandrawanshi
 
PPT
Operator & Expression in c++
bajiajugal
 
PPT
Basics of pointer, pointer expressions, pointer to pointer and pointer in fun...
Jayanshu Gundaniya
 
PPT
Advanced computer architecture lesson 5 and 6
Ismail Mukiibi
 
PDF
Embedded c
Nandan Desai
 
PPTX
design of high speed performance 64bit mac unit
Shiva Narayan Reddy
 
PPTX
Inline Functions and Default arguments
Nikhil Pandit
 
PPTX
Materi php
Mizuhashi Yuki
 
Embedded C - Lecture 4
Mohamed Abdallah
 
Microchip's PIC Micro Controller
Midhu S V Unnithan
 
Introduction to Embedded Systems a Practical Approach
Amr Ali (ISTQB CTAL Full, CSM, ITIL Foundation)
 
Addressing modes
Asif Iqbal
 
Question Bank Microprocessor 8085
Nilesh Bhaskarrao Bahadure
 
C Programming - Refresher - Part II
Emertxe Information Technologies Pvt Ltd
 
Programming with arduino
Makers of India
 
Compiler vs Interpreter-Compiler design ppt.
Md Hossen
 
Introduction with Programming Language
Saroar Zahan Sojib
 
8086 MICROPROCESSOR
Akhila Rahul
 
8051 Addressing Modes
Senthil Kumar
 
What is Arduino ?
Niket Chandrawanshi
 
Operator & Expression in c++
bajiajugal
 
Basics of pointer, pointer expressions, pointer to pointer and pointer in fun...
Jayanshu Gundaniya
 
Advanced computer architecture lesson 5 and 6
Ismail Mukiibi
 
Embedded c
Nandan Desai
 
design of high speed performance 64bit mac unit
Shiva Narayan Reddy
 
Inline Functions and Default arguments
Nikhil Pandit
 
Materi php
Mizuhashi Yuki
 
Ad

Similar to Reference Parameter, Passing object by reference, constant parameter & Default parameter (20)

PPTX
Fundamental of programming Fundamental of programming
LidetAdmassu
 
PPTX
Amit user defined functions xi (2)
Arpit Meena
 
PPTX
FUNCTIONS, CLASSES AND OBJECTS.pptx
DeepasCSE
 
PPT
16717 functions in C++
LPU
 
DOCX
Functions assignment
Ahmad Kamal
 
PPTX
Parameter passing to_functions_in_c
ForwardBlog Enewzletter
 
PPT
Dd3.15 thru-3.21-advanced-functions
temkin abdlkader
 
PPTX
Classes function overloading
ankush_kumar
 
PPTX
Functions1
DrUjwala1
 
PPTX
Programming Fundamentals lecture-10.pptx
singyali199
 
PDF
Functionssssssssssssssssssssssssssss.pdf
bodzzaa21
 
PPT
Functions
PatriciaPabalan
 
PPTX
Chapter 4
temkin abdlkader
 
PPT
Oop1
Vaibhav Bajaj
 
PPT
Lecture#7 Call by value and reference in c++
NUST Stuff
 
PPTX
C++ lecture 03
HNDE Labuduwa Galle
 
PPTX
Function Overloading Call by value and call by reference
TusharAneyrao1
 
PDF
Functions in C++.pdf
LadallaRajKumar
 
PPTX
Function C++
Shahzad Afridi
 
Fundamental of programming Fundamental of programming
LidetAdmassu
 
Amit user defined functions xi (2)
Arpit Meena
 
FUNCTIONS, CLASSES AND OBJECTS.pptx
DeepasCSE
 
16717 functions in C++
LPU
 
Functions assignment
Ahmad Kamal
 
Parameter passing to_functions_in_c
ForwardBlog Enewzletter
 
Dd3.15 thru-3.21-advanced-functions
temkin abdlkader
 
Classes function overloading
ankush_kumar
 
Functions1
DrUjwala1
 
Programming Fundamentals lecture-10.pptx
singyali199
 
Functionssssssssssssssssssssssssssss.pdf
bodzzaa21
 
Functions
PatriciaPabalan
 
Chapter 4
temkin abdlkader
 
Lecture#7 Call by value and reference in c++
NUST Stuff
 
C++ lecture 03
HNDE Labuduwa Galle
 
Function Overloading Call by value and call by reference
TusharAneyrao1
 
Functions in C++.pdf
LadallaRajKumar
 
Function C++
Shahzad Afridi
 
Ad

More from Meghaj Mallick (20)

PPT
24 partial-orderings
Meghaj Mallick
 
PPTX
PORTFOLIO BY USING HTML & CSS
Meghaj Mallick
 
PPTX
Introduction to Software Testing
Meghaj Mallick
 
PPTX
Introduction to System Programming
Meghaj Mallick
 
PPTX
MACRO ASSEBLER
Meghaj Mallick
 
PPTX
Icons, Image & Multimedia
Meghaj Mallick
 
PPTX
Project Tracking & SPC
Meghaj Mallick
 
PPTX
Peephole Optimization
Meghaj Mallick
 
PPTX
Routing in MANET
Meghaj Mallick
 
PPTX
Macro assembler
Meghaj Mallick
 
PPTX
Architecture and security in Vanet PPT
Meghaj Mallick
 
PPTX
Design Model & User Interface Design in Software Engineering
Meghaj Mallick
 
PPTX
Text Mining of Twitter in Data Mining
Meghaj Mallick
 
PPTX
DFS & BFS in Computer Algorithm
Meghaj Mallick
 
PPTX
Software Development Method
Meghaj Mallick
 
PPTX
Secant method in Numerical & Statistical Method
Meghaj Mallick
 
PPTX
Motivation in Organization
Meghaj Mallick
 
PPTX
Communication Skill
Meghaj Mallick
 
PPT
Partial-Orderings in Discrete Mathematics
Meghaj Mallick
 
PPTX
Hashing In Data Structure
Meghaj Mallick
 
24 partial-orderings
Meghaj Mallick
 
PORTFOLIO BY USING HTML & CSS
Meghaj Mallick
 
Introduction to Software Testing
Meghaj Mallick
 
Introduction to System Programming
Meghaj Mallick
 
MACRO ASSEBLER
Meghaj Mallick
 
Icons, Image & Multimedia
Meghaj Mallick
 
Project Tracking & SPC
Meghaj Mallick
 
Peephole Optimization
Meghaj Mallick
 
Routing in MANET
Meghaj Mallick
 
Macro assembler
Meghaj Mallick
 
Architecture and security in Vanet PPT
Meghaj Mallick
 
Design Model & User Interface Design in Software Engineering
Meghaj Mallick
 
Text Mining of Twitter in Data Mining
Meghaj Mallick
 
DFS & BFS in Computer Algorithm
Meghaj Mallick
 
Software Development Method
Meghaj Mallick
 
Secant method in Numerical & Statistical Method
Meghaj Mallick
 
Motivation in Organization
Meghaj Mallick
 
Communication Skill
Meghaj Mallick
 
Partial-Orderings in Discrete Mathematics
Meghaj Mallick
 
Hashing In Data Structure
Meghaj Mallick
 

Recently uploaded (20)

PDF
Media Training for Authors: Producing Videos & Nailing Interviews
Paula Rizzo
 
PDF
Mathematics Grade 11 Term 1 Week 1_2021.pdf
MalepyaneMokgatle
 
PPTX
Building a Strong and Ethical Digital Professional Identity
khalyaniramjan49
 
PDF
SXSW Panel Picker: Placemaking: Culture is the new cost of living
GabrielCohen28
 
PPTX
Describing the Organization's General Environment Identifying the Most Impact...
auntorkhastagirpujan
 
PDF
Developing Accessible and Usable Security Heuristics
Daniela Napoli
 
PPTX
Iconic Destinations in India: Explore Heritage and Beauty
dhorashankar
 
PPTX
“Mastering Digital Professionalism: Your Online Image Matters”
ramjankhalyani
 
PDF
Enhancing Bambara Groundnut Production Through Improved Agronomic Practices
Francois Stepman
 
PPTX
Information Security and Risk Management.pptx
prembasnet12
 
PPTX
AMFI - Investor Awareness Presentation.pptx
ssuser89d308
 
PDF
Advanced-Web-Design-Crafting-the-Future-Web (1).pdf
vaghelavidhiba591
 
PPTX
Working-with-HTML-CSS-and-JavaScript.pptx
badalsenma5
 
PPTX
Intellectual Property Rights in India.pptx
SurbhitShukla2
 
DOCX
Ss Peter & Paul Choir Formation Training
kiambutownshipsecond
 
PPTX
garment-industry in bangladesh. how bangladeshi industry is doing
tanvirhossain1570
 
PPTX
GAMABA AWARDEES GINAW BILOG AND SALINTA MONON BY REYMART
purezagambala458
 
PPTX
Remote Healthcare Technology Use Cases and the Contextual Integrity of Olde...
Daniela Napoli
 
PPTX
How do Company Analysis Short Term and Long Term Investment.pptx
auntorkhastagirpujan
 
PPTX
milgram study as level psychology core study (social approach)
dinhminhthu1405
 
Media Training for Authors: Producing Videos & Nailing Interviews
Paula Rizzo
 
Mathematics Grade 11 Term 1 Week 1_2021.pdf
MalepyaneMokgatle
 
Building a Strong and Ethical Digital Professional Identity
khalyaniramjan49
 
SXSW Panel Picker: Placemaking: Culture is the new cost of living
GabrielCohen28
 
Describing the Organization's General Environment Identifying the Most Impact...
auntorkhastagirpujan
 
Developing Accessible and Usable Security Heuristics
Daniela Napoli
 
Iconic Destinations in India: Explore Heritage and Beauty
dhorashankar
 
“Mastering Digital Professionalism: Your Online Image Matters”
ramjankhalyani
 
Enhancing Bambara Groundnut Production Through Improved Agronomic Practices
Francois Stepman
 
Information Security and Risk Management.pptx
prembasnet12
 
AMFI - Investor Awareness Presentation.pptx
ssuser89d308
 
Advanced-Web-Design-Crafting-the-Future-Web (1).pdf
vaghelavidhiba591
 
Working-with-HTML-CSS-and-JavaScript.pptx
badalsenma5
 
Intellectual Property Rights in India.pptx
SurbhitShukla2
 
Ss Peter & Paul Choir Formation Training
kiambutownshipsecond
 
garment-industry in bangladesh. how bangladeshi industry is doing
tanvirhossain1570
 
GAMABA AWARDEES GINAW BILOG AND SALINTA MONON BY REYMART
purezagambala458
 
Remote Healthcare Technology Use Cases and the Contextual Integrity of Olde...
Daniela Napoli
 
How do Company Analysis Short Term and Long Term Investment.pptx
auntorkhastagirpujan
 
milgram study as level psychology core study (social approach)
dinhminhthu1405
 

Reference Parameter, Passing object by reference, constant parameter & Default parameter

  • 1. BIRLA INSTITUTE OF TECHNOLOGY MESRA, JAIPUR CAMPUS :- TARUN TIWARI(MCA/25007/18) :- NIKHIL AGRAWAL(MCA/25004/18) TOPIC:- REFERENCE PARAMETERS ,Passing object by reference , CONSTANT PARAMETERS & DEFAULT PARAMETER
  • 2. REFERENCE PARAMETERS & CONSTANT PARAMETERS TARUN TIWARI
  • 3. REFERENCE PARAMETERS • In call by reference method the called function does not create its own copy rather it refers to original value only by different name i.e. reference. • When function is called by reference then, the formal parameter become reference or alias to the actual parameter in calling function. • To have a function with multiple outputs, we have to use pass by reference.
  • 4. • We use &to denote a parameter that is passed by reference: Syntax: <type>& <variable> Examples: • void Increment(int& Number); • void SumAve (double, double, double&, double&); • The corresponding argument must be a variable. Increment(Inc); SumAve(2.5, y+3, sum, mean);
  • 5. Example of Call By Reference #include <iostream.h> 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; } x=2, y=6, z=14 Void duplicate (int& a, int& b, int& c) x y z duplicate( x , y , z )
  • 6. Advantages of reference parameters • We can return multiple values from a function • Because a copy of the argument is not made, it is fast, even when used with large structs or classes. • Reference must be initialized Disadvantages of reference parameters • Many potential scenarios can occur • Programs are difficult to understand sometimes • Un-wanted Aliases
  • 7. • The const modifier can be applied to formal parameter declarations • The constant parameter received by the function can not be changed in the body of the function. CONSTANT PARAMETERS • const indicates that the function may not modify the parameter
  • 8. const type parameter DECLARATION OF CONSTANT PARAMETERS return_type FunName(const type1 parameter1, const type2 parameter2, ..., const typeN parameterN) { ... }
  • 9. EXAMPLE OF CONSTANT PARAMETERS double Area( const double radius) { return double (3.1415 * radius * radius); } double area; area = Area(5.5); area = 95.0304 double r = 7.88; area = Area(r); area = 195.07
  • 10. • If you try to change the value of the radius constant in the Area() function, for example radius = 2.88; • the compiler will generate an error: 'radius': you cannot assign to a variable that is const.
  • 11. PASSING OBJECTS BY REFERENCE & DEFAULT PARAMETERS. NIKHIL AGRAWAL
  • 12. PASSING OBJECT BY REFERENCE  One situation where it is absolutely mandatory to use a reference parameter is when we pass a Stream object to a function.  The reason is, When we extract data from a stream or insert data into a stream ,we are changing the stream.  As we know, if we passed the stream object by value, any changes that we made to the stream object would be made to a copy of the stream object, not to the actual object.  Thus whenever we need to pass a stream to a function, we must pass the stream by reference.
  • 13. Example :The following function writes an integer value to a stream that is passed as the parameter to the function :- Void OutputValue(ostream &out, int value){ out <<“ Value is “<< Value<<endl; return; } The next line of code uses the OutputValue() to write the value k to the stream cout :- OutputValue(cout,k);
  • 14. • Functions that output values to a stream are useful when we need to output several values along with labelling information from several places in a program. • We might use such a function to write data to the display as well as to a log file for later examination. • Another use would be to help debug the program.
  • 15.  Example : Suppose , for example, that we wish to “watch” Sort3() function as it sorts the values :- Void ShowValues(ostream &out , int a, int b, int c) { Out <<“a: “<<a<<endl; Out<<“b: “<<b<<endl; Out<<“c: “<<c<<endl; return; } //sort three numbers into ascending order Void Sort3(int &a, int &b, int &c) { If(a>b) swap(a,b); ShowValues(clog, a, b, c); If(a>c) swap(a,c); ShowValues(clog, a, b, c); If(b>c) swap(b,c); ShowValues(clog, a, b, c);
  • 16.  We can also put the ability to pass an input stream as a parameter to a function to good use.  For example : • Suppose we are writing a program to process data from a file. • Program development and testing will go faster if the program takes the input from the keyboard. • We can quickly test the program by typing in data, rather than creating a test file each time we want to test the program on different data. • However ,eventually the program will be reading data from a file. • We do not want to write the program so that it accepts input from the keyboard and then , when the program is complete , have to make extensive changes to the program so that it operates on a different stream. • We can handle this situation by writing any functions that extract input to accept as a parameter the stream to read data from .
  • 17. Program : bool ReadValues (istream &in, int &v1, int &v2, int &v3) { if ( in == cin) cout<<“ Please enter three numbers”; if ( in >> v1 >> v2 >> v3) return true; else return false; }
  • 18. DEFAULT ARGUMENTS  A default argument is a value provided in function declaration that is automatically assigned by the compiler if caller of the function doesn’t provide a value for the argument with default value.  Syntax: f _type f_name (arg1,arg2,arg3=value).  When a default argument is placed then all the other arguments after that must be default arguments only.
  • 19. DEFAULT ARGUMENTS (EXAMPLE) int sum(int x,int y,int z=0,int w=0) { return(x+y+z+w); } int main() { cout<<sum(10,15)<<endl; cout<<sum(10,15,25)<<endl; cout<<sum(10,15,25,30)<<endl; return 0; } • OUTPUT: 25 50 80
  • 20. DEFAULT ARGUMENTS  Default arguments are overwritten when calling function provides values for them. For example, calling of function sum(10, 15, 25, 30) overwrites the value of z and w to 25 and 30 respectively.  During calling of function, arguments from calling function to called function are copied from left to right. Therefore, sum(10, 15, 25) will assign 10, 15 and 25 to x, y and z. Therefore, default value is used for w only.
  • 21. DEFAULT ARGUMENTS The default parameter method is especially useful when one wants to set default criteria so that the function can be called with or without parameters. Default arguments are different from constant arguments as constant arguments can’t be changed whereas default arguments can be overwritten if required.