Blogger templates

Pages

Friday, 18 May 2012

Write a C Program To Calculate The Area of Triangle

Area_Of_Triangle

Formula of Area of Triangle:
  • Area = ( s (s-a) (s-b) (s-c) ) ^ (1/2)
  • where s = (a+b+c) / 2
  • a , b and c are the Sides of Triangle.
Statement of C Program: Write a Program to Find the Area of a Triange , given the Three Sides of Triangle:

#include<stdio.h>
#include<conio.h>
void main()

{
int a, b, c, s, Area;
clrscr();
printf(" Enter the values of a,b and c\n ");
scanf(" %d %d %d " , &a, &b, &c);

S=(a+b+c)/2;
Area = sqrt ( s (s-a) (s-b) (s-c) );                                  // sqrt used for Square Root
printf(" Area of Triangle = %d\n " , Area);
}

Output:
 Enter the values of a, b and c
 3
 4
 5
 Area of Triangle = 6


0 comments:

Post a Comment