# Calculate area of right angle triangle

To calculate the area of a right angle triangle, you need to know the lengths of two of its sides, typically denoted as base (b) and height (h). Then you can use the following formula:

Area = (1/2) * base * height

So, if you know the lengths of the base and height of a right angle triangle, you can simply plug them into this formula and calculate the area.

For example, if the base of a right angle triangle is 4 units and the height is 3 units, the area would be:

```Area = (1/2) * 4 * 3
= 6 square units```

Therefore, the area of this right angle triangle would be 6 square units.

Here given code implementation process.

``````//C Program
//Calculate area of right angle triangle
#include <stdio.h>

///Calculate area of right angle triangle by given base and height
void right_angle_triangle(double base, double height)
{
//Calculate area of right angle triangle
double area = 0.5 * base * height;
//Display the result of right angle triangle area
printf(" Triangle Size [ base : %lf, height : %lf ] ", base, height);
printf("\n Area : %lf\n\n", area);
}
int main()
{
//Test Cases
right_angle_triangle(10.9, 20);
right_angle_triangle(7, 10);
right_angle_triangle(20, 20.6);
right_angle_triangle(4, 8);
return 0;
}``````

#### Output

`````` Triangle Size [ base : 10.900000, height : 20.000000 ]
Area : 109.000000

Triangle Size [ base : 7.000000, height : 10.000000 ]
Area : 35.000000

Triangle Size [ base : 20.000000, height : 20.600000 ]
Area : 206.000000

Triangle Size [ base : 4.000000, height : 8.000000 ]
Area : 16.000000
``````
``````// Java Program
// Calculate area of right angle triangle
class TriangleArea
{
///Calculate area of right angle triangle by given base and height
public void right_angle_triangle(double base, double height)
{
//Calculate area of right angle triangle
double area = 0.5 * base * height;
//Display the result of right angle triangle area
System.out.print(" Triangle Size [ base : " + base + ", height : " + height + " ] ");
System.out.print("\n Area : " + area + "\n\n");
}
public static void main(String[] args)
{
TriangleArea obj = new TriangleArea();
//Test Cases
obj.right_angle_triangle(10.9, 20);
obj.right_angle_triangle(7, 10);
obj.right_angle_triangle(20, 20.6);
obj.right_angle_triangle(4, 8);
}
}``````

#### Output

`````` Triangle Size [ base : 10.9, height : 20.0 ]
Area : 109.0

Triangle Size [ base : 7.0, height : 10.0 ]
Area : 35.0

Triangle Size [ base : 20.0, height : 20.6 ]
Area : 206.0

Triangle Size [ base : 4.0, height : 8.0 ]
Area : 16.0
``````
``````// C++ Program
// Calculate area of right angle triangle
#include<iostream>

using namespace std;
class TriangleArea
{
public:
///Calculate area of right angle triangle by given base and height
void right_angle_triangle(double base, double height)
{
//Calculate area of right angle triangle
double area =( 0.5 * (base * height));
cout << " Triangle Size [ base : " << base << ", height : " << height << " ] ";
cout << "\n Area : " << area << "\n\n";
}
};
int main()
{
TriangleArea obj =  TriangleArea();
//Test Cases
obj.right_angle_triangle(10.9, 20);
obj.right_angle_triangle(7, 10);
obj.right_angle_triangle(20, 20.6);
obj.right_angle_triangle(4, 8);
return 0;
}``````

#### Output

`````` Triangle Size [ base : 10.9, height : 20 ]
Area : 109

Triangle Size [ base : 7, height : 10 ]
Area : 35

Triangle Size [ base : 20, height : 20.6 ]
Area : 206

Triangle Size [ base : 4, height : 8 ]
Area : 16
``````
``````// C# Program
// Calculate area of right angle triangle
using System;
class TriangleArea
{
///Calculate area of right angle triangle by given base and height
public void right_angle_triangle(double triangle_base, double height)
{
//Calculate area of right angle triangle
double area = 0.5 * triangle_base * height;
Console.Write(" Triangle Size [ base : " + triangle_base + ", height : " + height + " ] ");
Console.Write("\n Area : " + area + "\n\n");
}
public static void Main(String[] args)
{
TriangleArea obj = new TriangleArea();
//Test Cases
obj.right_angle_triangle(10.9, 20);
obj.right_angle_triangle(7, 10);
obj.right_angle_triangle(20, 20.6);
obj.right_angle_triangle(4, 8);
}
}``````

#### Output

`````` Triangle Size [ base : 10.9, height : 20 ]
Area : 109

Triangle Size [ base : 7, height : 10 ]
Area : 35

Triangle Size [ base : 20, height : 20.6 ]
Area : 206

Triangle Size [ base : 4, height : 8 ]
Area : 16
``````
``````<?php
// Php Program
// Calculate area of right angle triangle
class TriangleArea
{
///Calculate area of right angle triangle by given base and height
public  function right_angle_triangle(\$base, \$height)
{
//Calculate area of right angle triangle
\$area = 0.5 *\$base *\$height;
//Display the result of right angle triangle area
echo(" Triangle Size [ base : ". \$base .", height : ". \$height ." ] ");
echo("\n Area : ". \$area ."\n\n");
}
}

function main()
{
\$obj = new TriangleArea();
//Test Cases
\$obj->right_angle_triangle(10.9, 20);
\$obj->right_angle_triangle(7, 10);
\$obj->right_angle_triangle(20, 20.6);
\$obj->right_angle_triangle(4, 8);
}
main();``````

#### Output

`````` Triangle Size [ base : 10.9, height : 20 ]
Area : 109

Triangle Size [ base : 7, height : 10 ]
Area : 35

Triangle Size [ base : 20, height : 20.6 ]
Area : 206

Triangle Size [ base : 4, height : 8 ]
Area : 16
``````
``````// Node Js Program
// Calculate area of right angle triangle
class TriangleArea
{
///Calculate area of right angle triangle by given base and height
right_angle_triangle(base, height)
{
//Calculate area of right angle triangle
var area = 0.5 *base *height;
//Display the result of right angle triangle area
process.stdout.write(" Triangle Size [ base : " + base + ", height : " + height + " ] ");
process.stdout.write("\n Area : " + area + "\n\n");
}
}

function main(args)
{
var obj = new TriangleArea();
//Test Cases
obj.right_angle_triangle(10.9, 20);
obj.right_angle_triangle(7, 10);
obj.right_angle_triangle(20, 20.6);
obj.right_angle_triangle(4, 8);
}
main();``````

#### Output

`````` Triangle Size [ base : 10.9, height : 20 ]
Area : 109

Triangle Size [ base : 7, height : 10 ]
Area : 35

Triangle Size [ base : 20, height : 20.6 ]
Area : 206

Triangle Size [ base : 4, height : 8 ]
Area : 16
``````
``````#  Python 3 Program
#  Calculate area of right angle triangle
class TriangleArea :
# /Calculate area of right angle triangle by given base and height
def right_angle_triangle(self, base, height) :
# Calculate area of right angle triangle
area = 0.5 * base * height
# Display the result of right angle triangle area
print(" Triangle Size [ base : ", base ,", height : ", height ," ] ", end = "")
print("\n Area : ", area ,"\n\n", end = "")

def main() :
obj = TriangleArea()
# Test Cases
obj.right_angle_triangle(10.9, 20)
obj.right_angle_triangle(7, 10)
obj.right_angle_triangle(20, 20.6)
obj.right_angle_triangle(4, 8)

if __name__ == "__main__": main()``````

#### Output

`````` Triangle Size [ base :  10.9 , height :  20  ]
Area :  109.0

Triangle Size [ base :  7 , height :  10  ]
Area :  35.0

Triangle Size [ base :  20 , height :  20.6  ]
Area :  206.0

Triangle Size [ base :  4 , height :  8  ]
Area :  16.0
``````
``````#  Ruby Program
#  Calculate area of right angle triangle
class TriangleArea

# /Calculate area of right angle triangle by given base and height
def right_angle_triangle(base, height)

# Calculate area of right angle triangle
area = 0.5 * base * height
# Display the result of right angle triangle area
print(" Triangle Size [ base  :", base ,", height  :", height ," ] ")
print("\n Area  :", area ,"\n\n")
end
end
def main()

obj = TriangleArea.new()
# Test Cases
obj.right_angle_triangle(10.9, 20)
obj.right_angle_triangle(7, 10)
obj.right_angle_triangle(20, 20.6)
obj.right_angle_triangle(4, 8)
end
main()``````

#### Output

`````` Triangle Size [ base  :10.9, height  :20 ]
Area  :109.0

Triangle Size [ base  :7, height  :10 ]
Area  :35.0

Triangle Size [ base  :20, height  :20.6 ]
Area  :206.0

Triangle Size [ base  :4, height  :8 ]
Area  :16.0

``````
``````// Scala Program
// Calculate area of right angle triangle
class TriangleArea
{
///Calculate area of right angle triangle by given base and height
def right_angle_triangle(base: Double, height: Double): Unit = {
//Calculate area of right angle triangle
var area: Double = 0.5 * base * height;
//Display the result of right angle triangle area
print(" Triangle Size [ base : " + base + ", height : " + height + " ] ");
print("\n Area : " + area + "\n\n");
}
}
object Main
{
def main(args: Array[String]): Unit = {
var obj: TriangleArea = new TriangleArea();
//Test Cases
obj.right_angle_triangle(10.9, 20);
obj.right_angle_triangle(7, 10);
obj.right_angle_triangle(20, 20.6);
obj.right_angle_triangle(4, 8);
}
}``````

#### Output

`````` Triangle Size [ base : 10.9, height : 20.0 ]
Area : 109.0

Triangle Size [ base : 7.0, height : 10.0 ]
Area : 35.0

Triangle Size [ base : 20.0, height : 20.6 ]
Area : 206.0

Triangle Size [ base : 4.0, height : 8.0 ]
Area : 16.0
``````
``````// Swift Program
// Calculate area of right angle triangle
class TriangleArea
{
///Calculate area of right angle triangle by given base and height
func right_angle_triangle(_ base: Double, _ height: Double)
{
//Calculate area of right angle triangle
let area: Double = 0.5 * base * height;
//Display the result of right angle triangle area
print(" Triangle Size [ base : ", base ,", height : ", height ," ] ", terminator: "");
print("\n Area : ", area ,"\n\n", terminator: "");
}
}
func main()
{
let obj: TriangleArea = TriangleArea();
//Test Cases
obj.right_angle_triangle(10.9, 20);
obj.right_angle_triangle(7, 10);
obj.right_angle_triangle(20, 20.6);
obj.right_angle_triangle(4, 8);
}
main();``````

#### Output

`````` Triangle Size [ base :  10.9 , height :  20.0  ]
Area :  109.0

Triangle Size [ base :  7.0 , height :  10.0  ]
Area :  35.0

Triangle Size [ base :  20.0 , height :  20.6  ]
Area :  206.0

Triangle Size [ base :  4.0 , height :  8.0  ]
Area :  16.0
``````

## Comment

Please share your knowledge to improve code and content standard. Also submit your doubts, and test case. We improve by your feedback. We will try to resolve your query as soon as possible.