/*Write a C program that
reads three floating values
and check if it is possible
to make a triangle with them.
Also calculate the perimeter
of the triangle if the said
values are valid.
Test Data :
Input the first number: 25
Input the second number: 15
Input the third number: 35
Expected Output:
Perimeter = 75.0
*/
#include <stdio.h>
int main()
{
float num1,num2,num3,
parameter,i;
printf("Input the first\
number: ");
scanf("%f",&num1);
printf("Input the second\
number: ");
scanf("%f",&num2);
printf("Input the third\
number: ");
scanf("%f",&num3);
if(num1+num2>num3)
{
if(num2+num3>num2)
{
if(num1+num3>num1)
{
i=5;
}
}
}
if(i==5)
{
parameter=num1+num2+num3;
printf("Parameter = %.1f",
parameter);
}
else
{
printf("Triangle is not\
valid.");
}
getchar();
}
No comments:
Post a Comment