C program to find area of a triangle

Previous
Next

Input

            Enter base of the triangle: 10

            Enter height of the triangle: 15

Output

            Area of the triangle = 75 sq. units

Formula to calculate area

area = (base * height) / 2

#include <stdio.h>
int main()
{
	float base, height, area;
	
	printf("Enter base of the triangle: ");
	scanf("%f", &base);
	printf("Enter height of the triangle: ");
	scanf("%f", &height);
	
	area = (base * height) / 2;
	printf("Area of the triangle = %.2f sq. units", area);
	return 0;
}
Previous
Next

Add Comment

Courses Enquiry Form