What is default argument, C/C++ Programming

Assignment Help:

Default argument:

When the argument is missing then the function will read the default value of the missing

argument.  To make use of default argument functionality the argument must be initialized in the prototype or declaration.

Rules for declaring default argument:

1.   The default value must given from right to left arguments

2.   Cannot assign only the first argument as default when there is more than one argument.

3.   All the arguments may be default.

4.   When there is more than one argument the intermediate argument cannot be a default.

int f_def(int x, int y=20); // Default argument value initialized at prototype.

void main( )

{int a=10, b=15,c;

c = f_def(a, b); //The value of c is 15 c = f_def(a); // The value of c is 30

}

int f_def(int x, int y)

{ return (x+y);

}

 

 


Related Discussions:- What is default argument

.testvita, answer for tcs is working question

answer for tcs is working question

Array, Write a program to count the prime number in array

Write a program to count the prime number in array

Arithmetic operation, a program that declares and prompts the user to enter...

a program that declares and prompts the user to enter two integer and performs the five arithmetic operations

C program to find area of rectangle, Aim: To implement a program to find a...

Aim: To implement a program to find area of rectangle, surface area of box and volume of box using virtual functions. Code:                       class rect {

Explain the returning references from functions, Returning References from ...

Returning References from Functions Just as in passing the parameters by reference, returning a reference also doesn't return back a copy of the variable , instead an alias is

#padovan string in c, #write a program that counts the number of occurances...

#write a program that counts the number of occurances of the string in the n-th padovan string p(n)

Conversion operator, What is conversion operator? Explain it with example.

What is conversion operator? Explain it with example.

C programming, write a c program to solve exanple of lamis therom

write a c program to solve exanple of lamis therom

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd