Monday, January 20, 2014

C++ Program to Find the Volume of Shape Using Function Overloading

with 0 Comment
#include<iostream.h>
#include<conio.h>
int volume(int a);
double volume(int r,double h);
double volume(int l,int b,double h1);
int a,r,l,b;
double h,h1;
void main()
{
clrscr();
cout<<"\n Volume of Cube Cylinder & Rectangle";
cout<<"\n ***********************";
cout<<"\n Enter the Side of cube:";
cin>>a;
cout<<"\n Enter the Radius and Height of cylinder:";
cin>>r>>h;
cout<<"\n Enter the Length ,breadth and height of rectangle:";
cin>>b>>l>>h1;
int cb=volume(a);
cout<<"\n Volume of Cube:"<<cb;
double cy=volume(r,h);
cout<<"\n Volume of Cylinder:"<<cy;
double rect=volume(l,b,h1);
cout<<"\n Volume of Rectangle:"<<rect;
getch();
}
int volume(int a)
{
return(a*a*a);
}
double volume(int r,double h)
{
return(3.14*r*r*h);
}
double volume(int l,int b,double h1)
{
return(l*b*h1);
}



OUTPUT:
----------
Volume of Shapes:
**************
Enter the Side of the cube     :5
Enter the radius and height of the cylinder  :2 5 2.5
Enter the length,breadth & height of the rectangle : 10  12  5.6

Volume of cube       : 125
Volume of Cylinder   :66.04899
Volume of rectangle  :672

0 comments:

Post a Comment

Powered by Blogger.

Blog Archive