C Program to Input all Sides of a Triangle and Check Whether Triangle is Valid or Not Using If Else ?
Q:- Write a C Program to Input all Sides of a Triangle and Check Whether
Triangle is
Valid or Not Using If Else ?
Input
#include<stdio.h>
#include<conio.h>
int main()
{
int s1,s2,s3;
clrscr();
printf(“Enter Three Sides of
Triangle =”);
scanf(“%d%d%d”,&s1,&s2,&s3);
if((s1+s2)>s3)
{
printf(“Triangle is Valid.”);
}
else if((s2+s3)>s1)
{
printf(“Triangle is Valid.”);
}
else if((s1+s3)>s2)
{
printf(“Triangle is Valid.”);
}
else
{
printf(“Triangle is not Valid.”);
}
getch();
}
Output
Enter Three
Sides of Triangle =
7
4
10
Triangle is
Valid.
Comments
Post a Comment