C++ Program for finding volume of different shapes like Cube, Cuboid, Cylinder

 C++ Program for finding volume of different shapes like Cube, Cuboid, Cylinder

-Dinesh Kumar E

This is a simple C++ program for finding Volumes of Different shapes.

Code:

#include<iostream>
using namespace std;
int main()
{
int l,l1,b1,h1,r,h2,d,vcube,vcuboid,vcylinder;
cout<<"\n press the desier key 1-For cube 2-For cuboid 3- For Cylinder";
cin>>d;
if(d=1)
{
cout<<" \n Enter the Length of the cube";
cin>>l;
vcube=l*l*l;
cout<<"\n Volume of cube is "<<vcube;
}
else
if (d=2);
{
cout<<" \n Enter the Length of the cuboid";
cin>>l1;
cout<<" \n Enter the width of the cuboid";
cin>>b1;
cout<<" \n Enter the height of the cuboid";
cin>>h1;
vcuboid=l1*b1*h1;
cout<<"\n Volume of cuboid is "<<vcuboid;
}
if (d=3);
{
cin>>d;
cout<<" \n Enter the radius of the cylinder";
cin>>r;
cout<<" \n Enter the height of the cylinder";
cin>>h2;
vcylinder=3.14*r*r*h2;
cout<<"\n Volume of  is "<<vcylinder;
}}

Comments

Popular Posts