C Program to Calculate Area of a Right Angled Triangle

  • Write a C program to find the area of a right angled triangle.

Right-angled triangle is a triangle in which one angle is a right angle (90 degree). The sum of the other two angles of right-angled triangle is 90 degree. The relation between sides and angles of right angled triangle is the foundation of trigonometry and pythagoras theorem.

A branch of mathematics, known as trigonometry is based on right triangles. Most of the properties and formula of trigonometry is based on ratio and proportions of sides and angles of right triangle like Sine, Cosine, Tangent etc.

Sides of Right Triangle

  • Hypotenuse : Hypotenuse is the longest side of a right angled triangle which is opposite the right angle.
  • Sides : The two adjacent sides of the right angle. These are the two sides of a triangle which are not hypotenuse.

The relationship between the three sides of a right triangle is defined by Pythagoras theorem.

P2 + B2 = H2

Where, H is the length of the hypotenuse and P and B are the lengths of the the other two sides of right triangle.
Area of Right angled Triangle
If we know the length of base and perpendicular of a right angled triangle, then we can use below mentioned formula to find the area of a right triangle.

  • Area of Right Triangle = (1/2)* Base * Perpendicular

If we know the length of hypotenuse and altitude of a right triangle, then we can use below mentioned formulae to find area of a right triangle.

  • Area of Right Triangle = (1/2)* Hypotenuse * Altitude

Where, Altitude is the perpendicular distance between hypotenuse and vertex containing right angle(vertex opposite of hypotenuse).

C Program Area Of Right Triangle

C Program to find the area of a right angled triangle

In the following program, we will calculate the area of a right angles triangle using the above formula in which length of base and perpendicular is know. First of all, we take length of base and perpendicular as input from user using scanf function and store it in two floating point variables ‘base’ and ‘perpendicular’. In next line, it calculates the area of right triangle using above formula and stores the area in a floating point variable. Finally it prints the area of right triangle on screen using printf function.

C Program to Calculate Area of a Right Angled Triangle

/*
* C Program to calculate area of a 
* right angled triangle
*/
#include <stdio.h>
#include <conio.h>
 
int main(){
    float base, perpendicular, area;
    printf("Enter base of right angled triangle\n");
    scanf("%f", &base);
    printf("Enter perpendicular of right angled triangle\n");
    scanf("%f", &perpendicular);
    /* Area of right angled riangle = 
       (Base X Perpendicular)/2 */
    area =(base * perpendicular)/2;
    printf("Area of triangle : %0.4f\n", area);
     
    getch();
    return 0;
}

Program Output

Enter base of right angled triangle
3
Enter perpendicular of right angled triangle
4
Area of triangle : 6.0000

Properties of Right Triangle

  • The sun of the two acute internal angles of a right triangle is always 90 degree.
  • A triangle inscribed onside a semi circle with diameter as the hypotenuse and a vertex on curved boundary of semicircle is always a right triangle.
  • An isosceles right triangle is a right triangle, in which adjacent sides(non hypotenuse sides) of right angle are equal in length.
  • An acute right angle triangle is not possible because one of the internal angle of right triangle is always 90 degrees.

A right angle triangle is used in lots of scientific analysis, like

  • Finding the height of an distant object.
  • Finding the distance between earth and moon.
  • In engineering and architectural designs.
  • If we know the length of two sides of a right triangle, then we can find the length of third side using Pythagoras theorem.