Search This Blog

Thursday, October 13, 2011

Write a function to evaluate and display the area of a triangle

   1:  include<stdio.h>
   2:  #include<conio.h>
   3:  #include<math.h>
   4:  #include<stdlib.h>
   5:   
   6:  void showarea(float a,float b,float c);
   7:  void main()
   8:  {
   9:  float a,b,c;
  10:  printf("\nEnter the sides of triangle: ");
  11:  scanf("%f%f%f",&a,&b,&c);
  12:  showarea(a,b,c);
  13:  getch();
  14:  }
  15:   
  16:  void showarea(float a,float b,float c)
  17:  {
  18:  float s,area;
  19:  s=(a+b+c)/2.0;
  20:  area=s*(s-a)*(s-b)*(s-c);
  21:  area=sqrt(area);
  22:  printf("\nArea of triangel is: %f\n",area);
  23:  }

No comments:

Post a Comment