-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathweek-1_pq8.c
62 lines (56 loc) · 1.66 KB
/
week-1_pq8.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*8. Write a C program to check whether the triangle is
equilateral, isoscales or scalene triangle*/
#include<stdio.h>
int main(){
//Using Sides:--
// float s1, s2, s3;
// printf("Enter the length of the three sides of the triangle in cm :\n");
// scanf("%f %f %f", &s1, &s2, &s3);
// if(s1>0 && s2>0 && s3>0){
// switch(s1==s2 && s2==s3){
// case 1:
// printf("It is an equilateral triangle.");
// break;
// case 0:
// switch(s1==s2 || s2==s3 || s1==s3){
// case 1:
// printf("It is an isoscales triangle.");
// break;
// case 0:
// printf("It is an scalene triangle.");
// break;
// }
// }
// }
// else{
// printf("triangle is invalid");
// }
// }
//Using Angles:--
float a1, a2, a3, sum;
printf("Enter the three angles of the triangle in degree :\n");
scanf("%f %f %f", &a1, &a2, &a3);
sum =a1+a2+a3;
if(sum == 180 && a1>0 && a2>0 && a3>0){
switch (a1 == a2 && a2 == a3)
{
case 1:
printf("It is an equilateral triangle.");
break;
case 0:
switch (a1 == a2 || a2 == a3 || a1 == a3)
{
case 1:
printf("It is an isoscales triangle.");
break;
case 0:
printf("It is an scalene triangle.");
break;
}
}
}
else{
printf("The triangle is invalid.");
}
return 0;
}