คำนวณหาพื้นที่ของสามเหลี่ยม โดยรับค่าความสูงของสามเหลี่ยม (Height) และค่าของฐานสามเหลี่ยม (Base)
#include <stdio.h>
float AreaTriangle(float h, float b) {
return (h * b) / 2;
}
void main() {
float h;
float b;
float ans;
printf("Enter height : ");
scanf("%f", &h);
printf("Enter base : ");
scanf("%f", &b);
ans = AreaTriangle(h, b);
printf("Area = %f\n", ans);
}
ความคิดเห็น
แสดงความคิดเห็น