# C Program to Find Area of Triangle Using Function

In this C program, we will have a look at how to find the area of a triangle using the function in the C programming language.

How to find the area of the triangle?

We will use Heron’s or Hero’s formula to find the area of the triangle.

Heron’s or Hero’s formula:

Area of triangle=sqrt(s(s−a)(s−b)(s−c))

## C Program to Find Area of Triangle Using Function

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

double area_of_triangle(double, double, double); //function declaration
int main()
{
double a, b, c, area;
printf("Enter the lengths of sides of a triangle\n");
scanf("%lf%lf%lf", &a, &b, &c);
area = area_of_triangle(a, b, c);
printf("Area of the triangle = %.2lf\n", area);
return 0;
}

double area_of_triangle(double a, double b, double c) //function to find area of a triangle
{
double s, area;
s = (a+b+c)/2;
area = sqrt(s*(s-a)*(s-b)*(s-c));
return area;
}


Output

Enter the lengths of sides of a triangle
3
4
5
Area of the triangle = 6.00