#include <stdio.h>
// Function to calculate the area of the triangle
double calculate_triangle_area(double b, double h) {
return 0.5 * b * h; // Formula for the area of a triangle
}
void main() {
double b = 0.0, h = 0.0, total = 0.0;
printf("Input the base value: ");
printf("Input the height value: ");
if (b > 0 && h > 0) {
total = calculate_triangle_area(b, h);
printf("The area of the triangle is: %.2lf\n", total
); } else {
printf("Base and height must be positive values.\n"); }
}
I2luY2x1ZGUgPHN0ZGlvLmg+CgovLyBGdW5jdGlvbiB0byBjYWxjdWxhdGUgdGhlIGFyZWEgb2YgdGhlIHRyaWFuZ2xlCmRvdWJsZSBjYWxjdWxhdGVfdHJpYW5nbGVfYXJlYShkb3VibGUgYiwgZG91YmxlIGgpIHsKICAgIHJldHVybiAwLjUgKiBiICogaDsgLy8gRm9ybXVsYSBmb3IgdGhlIGFyZWEgb2YgYSB0cmlhbmdsZQp9Cgp2b2lkIG1haW4oKSB7CiAgICBkb3VibGUgYiA9IDAuMCwgaCA9IDAuMCwgdG90YWwgPSAwLjA7CgogICAgcHJpbnRmKCJJbnB1dCB0aGUgYmFzZSB2YWx1ZTogIik7CiAgICBzY2FuZigiJWxmIiwgJmIpOwoKICAgIHByaW50ZigiSW5wdXQgdGhlIGhlaWdodCB2YWx1ZTogIik7CiAgICBzY2FuZigiJWxmIiwgJmgpOwoKICAgIGlmIChiID4gMCAmJiBoID4gMCkgewogICAgICAgIHRvdGFsID0gY2FsY3VsYXRlX3RyaWFuZ2xlX2FyZWEoYiwgaCk7CiAgICAgICAgcHJpbnRmKCJUaGUgYXJlYSBvZiB0aGUgdHJpYW5nbGUgaXM6ICUuMmxmXG4iLCB0b3RhbCk7CiAgICB9IGVsc2UgewogICAgICAgIHByaW50ZigiQmFzZSBhbmQgaGVpZ2h0IG11c3QgYmUgcG9zaXRpdmUgdmFsdWVzLlxuIik7CiAgICB9Cn0K