How To Find Volume Of Rectangle Using Default Argument in c c++

Object Oriented Programming default argument refers to without getting input from the user to pass the value to and perform the process in these default argument we use the function name volume with passing three argument in c c++
Source Code programming Default Argument | CS 2209 – OBJECT ORIENTED PROGRAMMING LAB
#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 object oriented programming in c c++
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

Related post