Write a C Program To Calculate The Area of Triangle

Engg.... | 01:07 | | Best Blogger Tips
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


Please Share it! :)
Do you like this Story?

Get Free Email Updates Daily!

Follow us!

12 comments:

  1. I made the same program but when i run it..it give the output NAN.
    Can u explain why's that?

    ReplyDelete
    Replies
    1. we should also inluce a headerfile #include

      Delete
    2. Nt only a # include bt u sd write #include"math.h" before,dn run

      Delete
  2. This comment has been removed by the author.

    ReplyDelete
  3. we should also include
    a headerfile #include

    ReplyDelete
  4. it shows me function sqrt should written a prototype whats the solution

    ReplyDelete
  5. Very informative article.Thank you author for posting this kind of article .

    http://www.wikitechy.com/view-article/write-a-c-program-to-find-area-of-triangle-with-example-and-explanation


    Both are really good,
    Cheers,
    Venkat

    ReplyDelete