Write a C program to calculate the area of triangle.

Function Main
    Declare Real base
    Declare Real height
    Declare Real Area
    Output "Enter base: "
    Input base
    Output "Enter height:"
    Input height
    Output "The area of ​​the triangle is "
    Output (base * height) / 2
End



#include <stdio.h>
int main() {
    double base;
    double height;
    double area;
    printf("Enter base: ");
    scanf("%lf", &base);
    printf("Enter height:");
    scanf("%lf", &height);
    printf("The area of ​​the triangle is ");
    printf("%lf", base * height / 2 );
    return 0;
}




Enter base: 10.50
Enter height: 10.50
The area of ​​the triangle is: 55.125000

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.