Professional Documents
Culture Documents
Q 2
Q 2
#include<cmath>
using namespace std;
float area;
float calcAreaCircle();
float calcAreaRectangle();
float calcAreaTriangle();
int main()
{
char choice;
cout<<"SHAPE AREA CALCULATION"<<endl;
cout<<"\nC - Cirlce\n";
cout<<"\nR - Rectangle\n";
cout<<"\nT - Triangle\n"<<endl;
cout<<"Please Enter your choice : ";
cin>>choice;
switch(choice)
{
case 'C':
calcAreaCircle();
break;
case 'R' :
calcAreaRectangle();
break;
case 'T' :
calcAreaTriangle();
default :
cout<<"Error ! you entered wrong Input"<<endl;
break;
}
cout<<"The area of shape "<<choice<<" is : "<<area<<endl;
system("pause");
return 0;
float calcAreaCircle()
{
float radius;
cout<<"Enter the radius : ";
cin>>radius;
area = 3.142*pow(radius,2);
return area;
}
float calcAreaRectangle()
{
float length,width;
cout<<"Enter the Length : ";
cin>>length;
cout<<"Enter the Width : ";
cin>>width;
area = height*base/2;
return area;
}