This Program is for identifying the type of triangle using C program. This is a part of Mumbai University MCA Colleges C Programs MCA Sem 1
#include<stdio.h>
#include<conio.h>
void main()
{
float s1,s2,s3;
clrscr();
printf("Enter the sides of the triangle\n");
scanf("%f %f %f",&s1,&s2,&s3);
if((s1+s2<s3) || (s1+s3<s2) || (s2+s3<s1))
{
printf("It is not a valid triangle");
}
else
{
if(s1==s2 && s2==s3 && s1==s3)
{
printf("Its a equilateral triangle");
}
else if(s1==s2 || s2==s3 || s3==s1)
{
printf("Its a isoceles triangle");
}
else if(s1!=s2 || s2!=s3 || s3!=s1)
{
printf("The triangle is scalene triangle");
}
if(((s1*s1)+(s2*s2)==(s3*s3)) || ((s1*s1)+(s3*s3)==(s2*s2)) || ((s3*s3)+(s2*s2)==(s1*s1)))
{
printf("\nIts also a Right angeled triangle");
}
}
getch();
}
Hope this Program is useful to you in some sense or other. Keep on following this blog for more Mumbai University MCA College Programs. Happy Programming and Studying.
#include<stdio.h>
#include<conio.h>
void main()
{
float s1,s2,s3;
clrscr();
printf("Enter the sides of the triangle\n");
scanf("%f %f %f",&s1,&s2,&s3);
if((s1+s2<s3) || (s1+s3<s2) || (s2+s3<s1))
{
printf("It is not a valid triangle");
}
else
{
if(s1==s2 && s2==s3 && s1==s3)
{
printf("Its a equilateral triangle");
}
else if(s1==s2 || s2==s3 || s3==s1)
{
printf("Its a isoceles triangle");
}
else if(s1!=s2 || s2!=s3 || s3!=s1)
{
printf("The triangle is scalene triangle");
}
if(((s1*s1)+(s2*s2)==(s3*s3)) || ((s1*s1)+(s3*s3)==(s2*s2)) || ((s3*s3)+(s2*s2)==(s1*s1)))
{
printf("\nIts also a Right angeled triangle");
}
}
getch();
}
Hope this Program is useful to you in some sense or other. Keep on following this blog for more Mumbai University MCA College Programs. Happy Programming and Studying.
No comments:
Post a Comment