C++ Programming Blog

 
 
 

Image

 #include<iostream.h>
 #include<conio.h>

 int vol(int=1,int=2,int=3);

 main()
    {
       clrscr();

       int length;
       int width;
       int height;
       int volume;

       cout<<\"\\n Enter the value of length = \";
       cin>>length;

       cout<<\"\\n Enter the value of width = \";
       cin>>width;

       cout<<\"\\n Enter the value of heigth = \";
       cin>>height;

       volume=vol();
       cout<<\"\\n Volume with no argument passed = \"<<volume<<endl;

       volume=vol(length);
       cout<<\"\\n Volume with one argument passed = \"<<volume<<endl;

       volume=vol(length,width);
       cout<<\"\\n Volume with two argument passed = \"<<volume<<endl;

       volume=vol(length,width,height);
       cout<<\"\\n Volume with all argument passed = \"<<volume<<endl;

       getch();
       return 0;
    }


 //---------------------------  vol(int, int, int)  ----------------------//


 int vol(int l,int h,int w)
    {
       return l*h*w;
    }

 
 
Didn't find what you were looking for? Find more on Program to illustrate the use of default argument function