C Program to Find Total of Even Integers

C Program to Calculate Area of Triangle

C Program to Calculate area of triangle using the formula area=sqrt(s(s-a)(s-b)(s-c)) where a,b,c are the sides of the triangle and s=(a+b+c)/2. The main Objectives is to study about basic building blocks such as constants, variables, keywords,operators, expressions and input output statements in C language.

Save program in a file, Compile program, debug errors, Execute or Run program with necessary inputs. Verify the outputs obtained.

C Program to Calculate area of triangle

/*To evaluate area of triangle (sqrt(s(s-a)(s-b)(s-c)*/
#include<math.h>
#include<stdio.h>
void main()
{
int a,b,c;
float s,area;
clrscr();
printf("enter the values of a,b,c");
scanf("%d%d%d",&a,&b,&c);
s=(a+b+c)/2.0;
area=sqrt(s*(s-a)*(s-b)*(s-c));
printf("the area of a trangle is =%f",area);
getch();
}

Output

enter the values of a,b,c
15
20
30
The area of a trangle is = 133.317

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.

Let me know if you find any difficulty in understanding this C Program to Calculate area of triangle example and I would be glad to explain it further.

Online Training Tutorials