default argumentsa default argument is a value


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.

 

Request for Solution File

Ask an Expert for Answer!!
C/C++ Programming: default argumentsa default argument is a value
Reference No:- TGS0309341

Expected delivery within 24 Hours