C Program to Find Area of Right Angled Triangle

In this post, we will learn how to find the area of a right angled triangle using C Programming language.

Area of Right Angled Triangle = ½ x Base x Height

We will be using the above formula to compute the area of the right angled triangle. The user is asked to enter the base and height of the triangle.

So, without further ado, let’s begin this tutorial.

C Program to Find Area of Right Angled Triangle

// C Program to Find Area of Right Angled Triangle 
#include <stdio.h>
int main(){
    int base, height, area;
    
    // Asking for input
    printf("Enter the base: ");
    scanf("%d", &base);
    printf("Enter the height: ");
    scanf("%d", &height);
    
    // Calculating Area
    area = (base * height) / 2;
    
    // Displaying output
    printf("Area of the right angled triangle is: %d", area);
    return 0;
}

Output

Enter the base: 18
Enter the height: 12
Area of the right angled triangle is: 108

How Does This Program Work ?

    int base, height, area;

In this program, we have declared some int data type variables which will store the values of base and height of the triangle.

    // Asking for input
    printf("Enter the base: ");
    scanf("%d", &base);
    printf("Enter the height: ");
    scanf("%d", &height);

Then, the user is asked to enter the base and height of the triangle.

    // Calculating Area
    area = (base * height) / 2;

We calculate the area of the triangle using the formula:

Area = ½ x Base x Height

    // Displaying output
    printf("Area of the right angled triangle is: %d", area);

Finally, the area is printed using the printf() function.

Conclusion

I hope after going through this post, you understand how to find the area of a right angled triangle using C Programming language.

If you have any doubt regarding the program, feel free to contact us in the comment section. We will be delighted to help you.

Leave a Comment

Your email address will not be published. Required fields are marked *