C program to calculate the Area of a Triangle with Function

C program to calculate the Area of a Triangle with Function.

#include<stdio.h>
double triangleArea(double b, double height);

int main()
{
    double base, height;
    printf("Enter the base: ");
    scanf("%lf",&base);
    printf("Enter the height: ");
    scanf("%lf",&height);

    double area = triangleArea(base,height);
    printf("Triangle Area is %lf", area);
}

double triangleArea(double b, double h)
{
    return .5*b*h;
}

Leave a Comment