DEFAULT ARGUMENTS


SOURCE CODE:
#include<iostream.h>
#include<conio.h>
void volume(int l=10,int b=20,int h=15);
void volume(int l,int b,int h)
{
int vol;
vol=l*b*h;
cout<<"\n\nVOLUME OF  RECTANGLE IS:\t"<<vol;
}
void main()
{
clrscr();
cout<<"\n\n When length, breadth, height are default arguments";
volume();
cout<<"\n\n When breadth, height are default arguments";
volume(90);
cout<<"\n\n When height is default argument";
volume(20,15);
cout<<"\n\n When No default arguments";
volume(20,20,10);
getch();
}

OUTPUT:

When length, breadth, height are default arguments

VOLUME OF  RECTANGLE IS:    3000

When breadth, height are default arguments
   
VOLUME OF  RECTANGLE IS:    27000   

When height is default argument

VOLUME OF  RECTANGLE IS:    20000

When No default arguments

VOLUME OF  RECTANGLE IS:    4000
Previous
Next Post »

Still not found what you are looking for? Try again here.