Connect with one of the following accounts


Please wait while we redirect...

Views: 140   

Following program shows you how to calculate triangle area.
This program gets triangle base and height from user and calculates area and prints it using following formula
Area = base X height / 2

#include <stdio.h>

int main() {
    float triangleBase;
    float triangleHeight;

    printf("Enter the base of triangle:");
    scanf("%f", &triangleBase);

    printf("Enter the height of triangle:");
    scanf("%f", &triangleHeight);

    float areaOfTriangle = (triangleBase * triangleHeight) / 2;
    printf("Area of triangle is: %f", areaOfTriangle);


Enter the base of triangle: 45
Enter the height of triangle: 20
Area of triangle is: 450.000000

On By

Top Tutorials

Top Questions

Top Articles

Top Blogs

Top News