Logic to Calculate Area of Circle Rectangle and Triangle
Below are the formula to find the Area of Circle, Rectangle and Triangle. So first we are going to know the formulas and then after that we will implement in our program using switch case. So first we need to find the value of PI for area of radius, and for area of rectangle we need to length and width.
Now the most important is to find the area of Triangle with 3 sides, for this we will Use
Heron's formula with all three sides a,b and c of Triangle and divide by 2 after that we will apply a formula. Below is the C++ Program to Calculate Area of Circle Rectangle and Triangle Using Switch Statement.
Area of Circle Rectangle and Triangle Formulas
Area of Circle: 3.14*r*r (r=Radius)
Area of Rectangle: a*b
Area of Triangle: sqrt(s*(s-a)*(s-b)*(s-c));
Where S=(a+b+c)/2;
Output:
1.Area Of Circle
2.Area Of Rectangle
3.Area Of Triangle
Enter Your Choice :2
Enter the Length and Breadth of Rectangle:15 26 5
15
Area of Rectangle = 375
need an explanation for this answer? contact us directly to get an explanation for this answer