Area of triangle c program



#include<stdio.h>
int main()
{
    int h, b;
    float area;
    printf("Enter the height of the triangle : ");
    scanf("%d", &h);
    printf("Enter the base of the triangle : ");
    scanf("%d", &b);
    // formula for area of the triangle
    area = (h * b) / 2;
    printf("The area of the triangle is: ");
    printf("%f", area);
    return 0;
}


Output : 

Enter the height of the triangle : 10
Enter the base of the triangle : 20
The area of the triangle is: 100.000000

0 Comments