C Programming Code Examples C > Mathematics Code Examples Program to Calculate the Area of a Triangle Program to Calculate the Area of a Triangle This C Program calculates the area of a triangle given it's three sides. The formula or algorithm used is: Area = sqrt(s(s - a)(s - b)(s - c)), where s = (a + b + c) / 2 or perimeter / 2. and a, b & c are the sides of triangle. #include <stdio.h> #include <math.h> void main() { int s, a, b, c, area; printf("Enter the values of a, b and c \n"); scanf("%d %d %d", &a, &b, &c); /* compute s */ s = (a + b + c) / 2; area = sqrt(s * (s - a) * (s - b) * (s - c)); printf("Area of a triangle = %d \n", area); }