Pages

Labels

C Program to calculate area of triangle having base and height

Calculate area of triangle


#include <stdio.h>
#include <math.h>
main ()
{
  float b, h, a;
  printf ("Enter the Base of triangle:");
  scanf ("%f", &b);
  printf ("Enter the Height of triangle:");
  scanf ("%f", &h);
  a = b * h / 2;
  printf ("The area of Triangle is:%f\n", a);
  getch ();

}


Output:
Enter the Base of triangle: 5
Enter the Height of triangle: 6
The area of Triangle is: 15

How it works
Asks for two sides value of triangle and calculate it area.

Followers