9.12.2011

Area of triangle program

Q. Write a function to find the area of a triangle whose length of three sides is given.

Ans.

 /*Program to area of triangle using Heron's Formula*/
 #include<stdio.h>
 #include<math.h
 int main()
 {
  double area=0,x=10,y=8,z=7,s=0.0;
  s=(x+y+z)/2.0;
  area=(s*(s-x)*(s-y)*(s-z));
  printf("\nArea of triangle = %lf",area);

  return 0;
 }

/**************OUTPUT***************


Area of triangle = 773.43750075


************************************/


Output of Area Of Triangle C program
Figure: Screen shot for Area Of Triangle C program

3 comments:

  1. wrong program, it gives different output

    ReplyDelete
  2. Thanks for your feedback #U Dixit and #Asdi kr

    Now the code of above Area of Triangle C program has been updated and program is fully working.

    ReplyDelete