Professional Documents
Culture Documents
C program to find area of triangle: c programming code to calculate area of a triangle using Heron's or Hero's formula. User will enter the lengths of sides of triangle. Remember for a triangle to exist the sum of any two sides of a triangle must be greater than third side.
C programming code
/ *A s s u m i n gT r i a n g l ee x i s t s-v a l i di n p u tf r o mu s e r* / # i n c l u d e < s t d i o . h > # i n c l u d e < m a t h . h >
www.programmingsimplified.com/c/source-code/c-program-find-area-of-triangle 1/3
8/7/13
m a i n ( ) { d o u b l ea ,b ,c ,s ,a r e a ; p r i n t f ( " E n t e rt h es i d e so ft r i a n g l e \ n " ) ; s c a n f ( " % l f % l f % l f " , & a , & b , & c ) ; s=( a + b + c ) / 2 ; a r e a=s q r t ( s * ( s a ) * ( s b ) * ( s c ) ) ; p r i n t f ( " A r e ao ft r i a n g l e=% . 2 l f \ n " ,a r e a ) ; r e t u r n0 ; }
8/7/13
r e t u r na r e a ; }
www.programmingsimplified.com/c/source-code/c-program-find-area-of-triangle
3/3