>Write a program to find the volume of 3 objects; namely cube, cylinder and rectangular box using the same function name, volume().
>/* Write a program to find the volume of 3 objects; namely cube, cylinder and rectangular box using the same function name, volume().
programmed by:
Name: Jitendra Kr Yadav
Roll: 10116(NCIT-ELX)
date: July 12, 2011 */
#include <iostream.h>
#include <conio.h>
inlineint volume(int a)
{
return(a*a*a);
}
inline float volume(int a, int b)
{
return(3.14*a*a*b);
}
inlineint volume(int a, int b, int c)
{
return(a*b*c);
}
int main()
{
intlcu,lr,br,hr;
floatrcy,hcy;
cout<<“Enter the length of cube: “;
cin>>lcu;//length of cube
cout<<“Enter the radius of Cylinder: “;
cin>>rcy;//radius of cylinder
cout<<“Enter the height of a cylinder: “;
cin>>hcy;//height of cylinder
cout<<“Enter the length o the rectangle box: “;
cin>>lr;//length of rectangular box
cout<<“Enter the breadth of rectangl box: “;
cin>>br;//breadth of rectangular box
cout<<“Enter the height of rectangle box: “;
cin>>hr;//height of rectangular box
cout<<“The volume of cube is: “<<volume(lcu)<<endl<<“The volume of Cylinder is: “<<volume(rcy,hcy)<<endl<<“The volume of rectangular box is: “<<volume(lr,br,hr);
getch();
return(0);
}
Output Sample:
Enter the length of cube: 2
Enter the radius of Cylinder : 3
Enter the height of a cylinder: 4
Enter the length of the rectangular box: 5
Enter the breadth of rectangular box: 6
Enter the height of rectangular box: 7
The volume of cube is: 8
The volume of Cylinder is: 113.04
The Volume of rectangular box is: 210