Chapter - 3: The Decision Control

If the three sides of a triangle are entered through the keyboard, write a program to check whether the triangle is an isosceles, equilateral, scalene or right-angled triangle.


G
Sections
6
Exercises

A

B

C

D

E

F

G

H

I

J

K

1

2

3

4

5

6

7

8

9

10

11

13

#include<stdio.h>
#include<conio.h>
int main()
{
	float a,b,c;
	
	printf("\nEnter the sides of the triangle : ");
	scanf("%f%f%f", &a, &b, &c);
	
	if(a == b && a == c)
		printf("\nThe triangle is equilateral triangle.");
	
	if(a != b && b != c && a != c)
		printf("\nThe triangle is scalene.");
		
	if((pow(a,2) + pow(b,2) == pow(c,2)) || (pow(c,2) + pow(b,2) == pow(a,2)) || pow(a,2) + pow(c,2) == pow(b,2))
		printf("\nThe triangle is right triangle.");
		
	if((a == b) && a != c|| (a == c) && a!= b || (c == b) && c != a)
		printf("\nThe triangle is isosceles.");
	
	getch();
	return 0;
}

© 2020 Garbage Valuegarbage value logo