Skip to content

C Program to find area of triangle using Heron’s Formula

by yashan on January 31st, 2012

Write a Program in C programming language to find the area of triangle using Heron’s formula. Below is the code of the C program -


/* C program to find area of trianlge using Heron's formula */

#include<stdio.h>
#include<math.h>
void main()
{
     float a,b,c,s=0,area=0;
     
     printf("Enter the length of sides of triangle \n");
     scanf("%f %f %f",&a,&b,&c);
     
     s = (a+b+c)/2.0; /* s is semi-perimeter */
     area = (sqrt)(s*(s-a)*(s-b)*(s-c));
     
     printf("Area of triangle =\t %f",area);
     getch();
}

Input -
a = 6
b = 4
c = 5

Output-

Area of triangle = 9.9215

 

One Comment
  1. I see a lot of interesting articles on your website.
    You have to spend a lot of time writing, i know how to save you a lot of work, there is a tool that creates unique,
    google friendly posts in couple of seconds, just type in google – laranita’s free content source

Leave a Reply

Note: XHTML is allowed. Your email address will never be published.

Subscribe to this comment feed via RSS