-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTriangles check using switch case
More file actions
65 lines (65 loc) · 1.27 KB
/
Triangles check using switch case
File metadata and controls
65 lines (65 loc) · 1.27 KB
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
63
64
65
int main()
{
while(1)
{
int n,a,b,c,d;
printf("\n1.Isosceles triangle check\n");
printf("2.Right triangle check\n");
printf("3.Equilateral triangle check\n");
printf("4.Exit\n\n");
printf("Select an option:");
scanf("%d",&n);
switch(n)
{
case 1:
printf("Enter three nos");
scanf("%d %d %d",&a,&b,&c);
if(a+b>c && b+c>a && a+c>b)
{
if(a==b || b==c || a==c)
printf("Test pass");
else
printf("Test fail");
printf("\n");
}
else
printf("Triangle Not possible\n");
break;
case 2:
printf("Enter three nos");
scanf("%d %d %d",&a,&b,&c);
if(a+b>c && b+c>a && a+c>b)
{
if(c*c== a*a+ b*b || b*b==a*a+ c*c || a*a== c*c + b*b)
printf("Test pass");
else
printf("Test fail");
printf("\n");
}
else
printf("Triangle Not possible\n");
break;
case 3:
printf("Enter three nos");
scanf("%d %d %d",&a,&b,&c);
if(a+b>c && b+c>a && a+c>b)
{
if(a==b & b==c)
printf("Test pass");
else
printf("Test fail");
printf("\n");
}
else
printf("Triangle Not possible\n");
break;
case 4:
break;
default :
printf("Invalid entry\n\n");
}
if(n==4)
break;
}
return 0;
}