### WAP- Area of a triangle is given by the formula A=sqrt(S(S-a)(S-b)(S-c)), where a, b and c are sides of the triangle and 2S=a+b+c. Write a program to compute the area of the triangle given the values of a, b and c.

//E Balagurusamy, Programming In ANSI C,4E

//Exercise 1.10, page 22

#include <stdio.h>

#include <math.h>

#define a 10

#define b 10

#define c 10

int main(void)

{float S,area;

printf("\n\n");

S=(a+b+c)/2;

area=sqrt(S*(S-a)*(S-b)*(S-c));

printf("For a=%d, b=%d, c=%d,\n",a,b,c);

printf("the area of triangle is %f",area);

printf("\n\n");

return 0;

}

thank you

ReplyDeletei need this for my students

Glad to be of help Sir :)

ReplyDelete