C语言根据底和高计算三角形面积的程序

本文介绍了如何使用C语言程序,通过底和高计算三角形的面积,并附有示例。计算三角形面积的数学公式为:面积 = (底 * 高) / 2

程序允许用户输入三角形的底和高,然后使用这两个值计算出三角形的面积。

#include<stdio.h>

int main()
{
float base, height, area;

printf("\n Please Enter the Base of a Triangle : ");
scanf("%f", &base);

printf("\n Please Enter the Height of a Triangle : ");
scanf("%f", &height);

area = (base * height) / 2;

printf("\n The Area of a Triangle using Base and Height = %.2f\n", area);

return 0;
}
Program to find Area Of a Triangle using base and height