Explain default arguments, C/C++ Programming

Assignment Help:

Default Arguments

A default argument is a value that is automatically assigned to a formal variable, if the actual argument from the function call is omitted.

e.g.

void drawbox( int x1=1, int y1=1, int x2=25, int y2=80,

 int color=7);                                                // Prototype

 

  void main ( void )

 {

 drawbox(10,1,25,80,14); // parameters passed

 drawbox();   // uses default arguments        

}     

void drawbox( int x1, int y1, int x2, int y2,

          int color)

{

// Body of the function

                   }

 Function drawbox() draws a box around the edges of the coordinates passed as parameters. If these parameters are omitted, then the default values, as given in the declaration are passed.

 


Related Discussions:- Explain default arguments

Pointers, When declaring a variable of data type pointer, use the * in fron...

When declaring a variable of data type pointer, use the * in front of the variable name. These variables hold a memory location (like B45CDF), not an actual value like 30 or A:

#Padovan string, #A Padovan string P(n) for a natural number n is defined a...

#A Padovan string P(n) for a natural number n is defined as: P(0) = ‘X’ P(1) = ‘Y’ P(2) = ‘Z’ P(n) = P(n-2) + P(n-3), n>2 where + denotes string concatenation. For a string of

#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)

#titletrees.., #question.conversion of tree into binary tree.

#question.conversion of tree into binary tree.

Overloading unary operators, Overloading Unary Operators class sign ...

Overloading Unary Operators class sign {int a,b,c; public: sign(){}; sign(int,int,int); void putdata(void); void operator-(); }; void sign::operator-() {a=

C program to check factorial, C Program to check FACTORIAL   main() ...

C Program to check FACTORIAL   main() {             int i,j,m,fact,sum=0;           clrscr();           printf("ENTER THE NO.: ");           scanf("%d",&m);

Hw8, Asks the user for an integer. if the number is less than 21, ask them ...

Asks the user for an integer. if the number is less than 21, ask them for a number again; repeat this until you get a number bigger than 20. 20 is not an acceptable number. Once yo

C program to convert number to binary, Write a program in C that you will n...

Write a program in C that you will name "divide.exe", to divide one 32-bit twos-complement binary number by another, giving the quotient and the remainder, using the subtract-shift

State six typical application of primary cells, Normal 0 false ...

Normal 0 false false false EN-IN X-NONE X-NONE MicrosoftInternetExplorer4

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