Find the area and perimeter of right triangle in PL/SQL
Prerequisite – PL/SQL introduction
In PL/SQL code groups of commands are arranged within a block. A block group related declarations or statements. In declare part, we declare variables and between begin and end part, we perform the operations.
Given the lengths of hypotenuse, base, and height of a right triangle, the task is to find the area and perimeter of the triangle.
Input: hypotenuse = 10, base = 4, height = 14
Output: Area = 28, Perimeter = 28
Input: hypotenuse = 30, base = 10, height = 25
Output: Area = 125, Perimeter = 65
Formula for calculating area and perimeter:
Area of right triangle:
1/2 * base * height
Perimeter of triangle:
len of hypotenuse + len of base + len of height
Below is the required implementation:
hypotenuse := 10;
base := 4;
height := 14;
area := .5 * base * height;
perimeter := hypotenuse + height + base;
' Area of triangle is '
' Perimeter of triangle is '
Area of triangle is 28
Perimeter of triangle is 28