You are on page 1of 2

#include <stdio.h> #include <math.

h>

int main(void) { int a,b,c; double d,s,area;

/* Asking for user to input the value for a,b & c */

printf("Please input the length of A\n"); scanf("%d", &a);

printf("Please input the length of B\n"); scanf("%d", &b);

printf("Please input the length of C\n"); scanf("%d", &c);

/*Conditions*/

if (a<=0) printf("You entered an invalid value for length of A.\n"); if (b<=0) printf("You entered an invalid value for length of B. \n"); if (c<=0) printf("You entered an invalid value for length of C. \n");

if (c<(a+b)) printf("Given that A+B is more than C, area of Triangle cannot be computed. \n"); if (b<(a+c)) printf("Given that A+C is more than B, area of Triangle cannot be computed. \n"); if (a<(b+c)) printf("Given that B+C is more than A, area of Triangle cannot be computed. \n"); else s=(a+b+c)/2 ; d=s*(s-a)*(s-b)*(s-c) ; area=sqrt(d); printf("The area of the triangle with given values is %lf .", area);

return(0);

You might also like