本文介绍了如何使用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;
}
