A Program to Find the Area of a Triangle
In this example, we are giving a program to find the area of a triangle. The rule of finding the area of a triangle is: A = 0.5 * base * height.
Program to find the area of a triangle:
#include <stdio.h>#include <stdlib.h>int main() {float p, b, h, area;printf("Enter the value of base and height: ");scanf("%f %f", &b, &h);area = 0.5 * b * h;printf("Area of triangle: %.2f", area);return 0;}
Output:
Enter the value of base and height: 3, 4 Area of triangle: 6.00