Type of Triangle based on sides length coderinme

Type of Triangle based on sides length

To read the length of the three sides of a triangle (a,b,c) and determine what type of
triangle it is, based on the following cases:
If a>b+c no triangle is formed
If a2=b2+c2 a right angles triangle is formed.
If a2>b2+c2 an obtuse angles triangle is formed.
If a2=b2+c2 an acute angles triangle is formed.

#include<stdio.h>
int main()
{
int a,b,c,temp;
printf("Enter the 1st side of triangle: ");
scanf("%d",&a);
printf("Enter the 2nd side of triangle: ");
scanf("%d",&b);
printf("Enter the 3rd side of triangle: ");
scanf("%d",&c);
if ( b > a && b > c ) {
temp = a;
a = b;
b = temp;
}
else if( c > a && c > b ) {
temp = a;
a = c;
c = temp;
}
if( a > b + c)
printf("No triangle is Formed");
else if( (a * a) == (b * b + c * c ))
printf("A right angle triangle is formed");
else if( (a * a) > (b * b + c * c) )
printf("An obtuse angled triangle is formed");
else if( (a * a) < (b * b + c * c) )
printf("An acute angled triangle is formed");
getch();
return 0;
}

For more programs in C, visit our C Coder Archives

Type of Triangle based on sides length coderinme

All rights reserved. No part of this Post may be copied, distributed, or transmitted in any form or by any means, without the prior written permission of the website admin, except in the case of brief quotations embodied in critical reviews and certain other noncommercial uses permitted by copyright law. For permission requests, write to the owner, addressed “Attention: Permissions Coordinator,” to the admin @coderinme

Leave a reply:

Your email address will not be published.