Description
To calculate area of right angle triangle use formula. Area of Right Angle Triangle = ½ (Base × Perpendicular)
C/C++
/* C Program to calculate right angle triangle */ //Save it as AreaRightAngleTriangle.c #include<stdio.h> int main(){ float base, height, area; printf("Enter the base of triangle : "); scanf("%f",&base); printf("Enter the height of triangle : "); scanf("%f",&height); area = 0.5 * base * height; printf("The area of triangle : %.3f", area); return 0; }
Input: Enter the base of triangle : 2 Enter the height of triangle : 3 Output: The area of triangle : 3.000
Java
/* Java Program to calculate right angle triangle */ //Save it as AreaRightAngleTriangle.java import java.io.*; import java.util.Scanner; public class AreaRightAngleTriangle { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); float base, height, area; System.out.println("Enter the base of triangle : "); base = scanner.nextFloat(); System.out.println("Enter the height of triangle : "); height = scanner.nextFloat(); area = (float) (0.5 * base * height); System.out.println("The area of triangle : " + area); } }
Input: Enter the base of triangle : 2 Enter the height of triangle : 3 Output: The area of triangle : 3.0
Related Programs
1) Program to calculate area of a circle2) Program to calculate area of triangle
3) Program to calculate area of square
4) Program to calculate area of a Rectangle
5) Program to calculate volume and surface area of cube
6) Program to calculate volume and surface area of cylinder
7) Program to calculate Volume and Surface Area of Sphere