温馨提示×

如何用c语言求三角形面积的程序

小亿
86
2024-08-17 10:33:35
栏目: 编程语言
C语言开发者专用服务器限时活动,0元免费领,库存有限,领完即止! 点击查看>>

#include <stdio.h>

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

// Input base and height of the triangle
printf("Enter the base of the triangle: ");
scanf("%f", &base);

printf("Enter the height of the triangle: ");
scanf("%f", &height);

// Calculate the area of the triangle
area = 0.5 * base * height;

// Display the area of the triangle
printf("The area of the triangle is: %.2f\n", area);

return 0;

}

亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>

推荐阅读:c语言三角形面积如何求

0