#include <iostream>
#define PI 3.14
using
namespace
std;
float
volume(
float
side)
{
cout <<
"calculating volume of Cube.."
;
float
calculate_volume;
calculate_volume
= side * side * side;
return
calculate_volume;
}
float
volume(
float
length,
float
breadth,
float
height)
{
cout <<
"calculating volume of "
<<
"Rectangle.."
;
int
calculate_volume;
calculate_volume
= length * breadth * height;
return
calculate_volume;
}
float
volume(
double
radius,
double
height)
{
cout <<
"calculating volume of"
<<
" cylinder.."
;
float
calculate_volume;
calculate_volume
= PI * radius * radius * height;
return
calculate_volume;
}
void
swapvalues(
float
cylinder,
float
cube)
{
float
third_variable;
if
(cylinder == 0 || cube == 0) {
cout <<
"\nvalues are not assign"
;
return
;
}
cout <<
"\n\nValues before swapping"
;
cout <<
"\nvolume of cylinder :"
<< cylinder;
cout <<
"\nvolume of cube :"
<< cube;
third_variable = cube;
cube = cylinder;
cylinder = third_variable;
cout <<
"\n\nvalues after swapping "
;
cout <<
"\nvolume of cylinder :"
<< cylinder;
cout <<
"\nvolume of cube :"
<< cube;
}
int
main()
{
float
height, radius, length;
float
breadth, rectangleHeight;
float
volumeCube = 0;
float
volumeRectangle = 0;
float
volumeCylinder = 0;
float
side;
int
choice;
cout <<
"\n\n==== MENU ===="
;
cout <<
"\n\n1.Calculate volume "
<<
"of CUBE"
;
cout <<
"\n\n2.Calculate volume "
<<
"of RECTANGLE"
;
cout <<
"\n\n3.Calculate volume "
<<
"of CYLINDER"
;
cout <<
"\n\n4.PRESS '4' To SWAP "
<<
"VOLUMES OF CUBE AND "
"CYLINDER"
;
cout <<
"\n\n5.Exit"
;
while
(1) {
cout <<
"\n\nSelect your choice :"
;
cin >> choice;
switch
(choice) {
case
1:
cout <<
"\nEnter the side"
<<
" of cube :"
;
cin >> side;
volumeCube = volume(side);
cout <<
"\nVolume of cube is :"
<< volumeCube;
break
;
case
2:
cout <<
"\nEnter the length :"
;
cin >> length;
cout <<
"\nEnter the height :"
;
cin >> rectangleHeight;
cout <<
"\nEnter the breadth :"
;
cin >> breadth;
volumeRectangle
= volume(length, breadth,
rectangleHeight);
cout <<
"\nVolume of Rectangle is :"
<< volumeRectangle;
break
;
case
3:
cout <<
"\nEnter the Radius :"
;
cin >> radius;
cout <<
"\nEnter the height :"
;
cin >> height;
volumeCylinder = volume(
radius, height);
cout <<
"\nVolume of Cylinder is :"
<< volumeCylinder;
break
;
case
4:
swapvalues(volumeCylinder,
volumeCube);
break
;
case
5:
exit
(0);
}
}
return
0;
}