find area of a triangle

#include<stdio.h>
int main()
{
      float base, height, area;
      scanf("%f %f", &base,&height);
      area = (base * height) / 2;
       printf("Area of the triangle = %.2f sq. units", area);
     
     //%.2f is used to print fractional values only up to 2 decimal places. You can also use %f to print              up to 6 decimal places by default.
    return 0;
}
Input:
30 60
Output:
Area of the triangle = 900.00 sq. units

No comments:

Post a Comment