#include<iostream>
using namespace std;
#include<conio.h>
#define pi 3.142
void vol(int);
void vol(float, float);
void vol(float);
void main()
{
int ch,s;
float r,h,rad;
do
{
cout<<"----MENU----\n";
cout<<"1. Cube\n";
cout<<"2. Sphere\n";
cout<<"3. Cylinder \n";
cout<<"4. Exit \n";
cout<<"------------\n";
cout<<"Make a choice: ";
cin>>ch;
switch(ch)
{
case 1:
cout<<"Enter side of cube: ";
cin>>s;
vol(s);
break;
case 2:
cout<<"Enter radius of sphere: ";
cin>>r;
vol(r);
break;
case 3:
cout<<"Enter radius of cylinder: ";
cin>>rad;
cout<<"Enter height of cylinder: ";
cin>>h;
vol(rad,h);
break;
case 4:
exit(0);
default:
cout<<"Invalid Choice \n";
break;
}
}
while(ch!=4);
getch();
}
void vol(int s)
{
int v1;
v1=s*s*s;
cout<<"The volume of cube= "<<v1<<"\n\n";
}
void vol(float r)
{
float v2;
v2=(4.0/3.0)*pi*r*r*r;
cout<<"The volume of sphere= "<<v2<<"\n\n";
}
void vol(float rad,float h)
{
float v3;
v3=pi*rad*rad*h;
cout<<"The volume of cylinder= "<<v3<<"\n\n";
}
using namespace std;
#include<conio.h>
#define pi 3.142
void vol(int);
void vol(float, float);
void vol(float);
void main()
{
int ch,s;
float r,h,rad;
do
{
cout<<"----MENU----\n";
cout<<"1. Cube\n";
cout<<"2. Sphere\n";
cout<<"3. Cylinder \n";
cout<<"4. Exit \n";
cout<<"------------\n";
cout<<"Make a choice: ";
cin>>ch;
switch(ch)
{
case 1:
cout<<"Enter side of cube: ";
cin>>s;
vol(s);
break;
case 2:
cout<<"Enter radius of sphere: ";
cin>>r;
vol(r);
break;
case 3:
cout<<"Enter radius of cylinder: ";
cin>>rad;
cout<<"Enter height of cylinder: ";
cin>>h;
vol(rad,h);
break;
case 4:
exit(0);
default:
cout<<"Invalid Choice \n";
break;
}
}
while(ch!=4);
getch();
}
void vol(int s)
{
int v1;
v1=s*s*s;
cout<<"The volume of cube= "<<v1<<"\n\n";
}
void vol(float r)
{
float v2;
v2=(4.0/3.0)*pi*r*r*r;
cout<<"The volume of sphere= "<<v2<<"\n\n";
}
void vol(float rad,float h)
{
float v3;
v3=pi*rad*rad*h;
cout<<"The volume of cylinder= "<<v3<<"\n\n";
}
No comments:
Post a Comment