-
Notifications
You must be signed in to change notification settings - Fork 0
/
area.cpp
44 lines (37 loc) · 893 Bytes
/
area.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include <iostream>
using namespace std;
int main()
{
cout << "choose your choice: \n1:rectangle\n2:circle\n3:triangle\n";
int choice;
float pi = 3.14, area = 0;
cin >> choice;
switch (choice)
{
case 1:
cout << "enter the length and breadth of rectangle: ";
int length, breadth;
cin >> length >> breadth;
area = length * breadth;
break;
case 2:
cout << "enter the radius of circle: ";
int radius;
cin >> radius;
area = pi * radius * radius;
break;
case 3:
cout << "enter the base and height of triangle: ";
int base, height;
cin >> base >> height;
area = 0.5 * base * height;
break;
default:
cout << "invalid choice";
}
if (area > 0)
{
cout << "area of triangle is: " << area;
}
return 0;
}