-
Notifications
You must be signed in to change notification settings - Fork 16
/
10.c
44 lines (38 loc) · 915 Bytes
/
10.c
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 <stdio.h>
#include <math.h>
float perimeter(float a, float b, float c)
{
return a + b + c;
}
float area(float a, float b, float c)
{
float s = (a + b + c) / 2;
return sqrt((s - a) * (s - b) * (s - c));
}
int main()
{
float a, b, c;
char operation;
printf("Enter first side: ");
scanf("%f", &a);
printf("Enter second side: ");
scanf("%f", &b);
printf("Enter third side: ");
scanf("%f", &c);
printf("Enter one of the followings: ");
printf("\n(a) Perimeter of the triangle ");
printf("\n(b) Area of the triangle ");
printf("\n");
scanf(" %c", &operation);
switch (operation)
{
case 'a':
printf("Result -> %f\n", perimeter(a, b, c));
break;
case 'b':
printf("Result -> %f\n", area(a, b, c));
break;
default:
printf("Invalid operation\n");
}
}