You are on page 1of 2

#include<iostream>

#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 = length *width;


return area;
}
float calcAreaTriangle()
{
float height,base;
cout<<"Enter the height :";
cin>>height;
cout<<"Enter the base : ";
cin>>base;

area = height*base/2;
return area;
}

You might also like