# C++ To Calculate Area Of Circle ,Rectangle And Triangle Using Switch Case

Problem :- Write A C++  To Calculate Area Of Circle Rectangle And Triangle Using Switch Case

Logic :- Here Are Formula To Find Area of Circle ,Rectangle And Triangle now you Easily Got Solution . If you are having problem in switch Case then See  C Program For Remove All Vowels From A String Using Switch Case

Area Of Rectangle = a*b

Area Of Trianglesqrt(s*(s-a)*(s-b)*(s-c));

Where S=(a+b+c)/2;

Solution :-

#include<iostream>
#include<math.h>
using namespace std;
int main()
{
float a,b,c,s,r,area;
int ch;

cout<<"1.Area Of Circle";
cout<<"\n2.Area Of Rectangle";
cout<<"\n3.Area Of Triangle \n";
cin>>ch;

switch(ch)
{
case 1:
{
cout<<"\nEnter Radius Of The Circle: ";
cin>>r;
area=3.14*r*r;
break;
}
case 2:
{
cout<<"\nEnter Length And Breadth Of Rectangle:";
cin>>a>>b;
area=a*b;
break;
}
case 3:
{
cout<<"\nEnter Three Sides Of The Triangle:";
cin>>a>>b>>c;
s=(a+b+c)/2;
area=sqrt(s*(s-a)*(s-b)*(s-c));
break;
}
default: cout<<"\n Invalid Choice Try Again...!!!";
break;
}

cout<<"Area = "<<area<<endl;
return 0;
}

Output:-