**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.

Examples:

Input:hypotenuse = 10, base = 4, height = 14Output:Area = 28, Perimeter = 28Input:hypotenuse = 30, base = 10, height = 25Output: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:

`DECLARE` ` ` `-- declare variable side1, side2, ` ` ` `-- base, height, area and perimeter ` ` ` `-- and these six variable datatype ` ` ` `-- are float ` ` ` `hypotenuse ` `FLOAT` `; ` ` ` `base ` `FLOAT` `; ` ` ` `height ` `FLOAT` `; ` ` ` `area ` `FLOAT` `; ` ` ` `perimeter ` `FLOAT` `; ` `BEGIN` ` ` `-- here we assign the value in ` ` ` `-- side1, side2, base, height ` ` ` `hypotenuse := 10; ` ` ` ` ` `base := 4; ` ` ` ` ` `height := 14; ` ` ` ` ` `area := .5 * base * height; ` ` ` ` ` `perimeter := hypotenuse + height + base; ` ` ` ` ` `dbms_output.Put_line(` `' Area of triangle is '` ` ` `|| area); ` ` ` ` ` `dbms_output.Put_line(` `' Perimeter of triangle is '` ` ` `|| perimeter); ` `END` `; ` `-- Program End ` |

*chevron_right*

*filter_none*

**Output :**

Area of triangle is 28 Perimeter of triangle is 28

## Recommended Posts:

- Area and Perimeter of Rectangle in PL/SQL
- Area and Perimeter of a circle in PL/SQL
- Difference between SQL and PLSQL
- PLSQL | LOG Function
- PLSQL | INSTR Function
- PLSQL | INSTRB Function
- PLSQL | LENGTH2 Function
- PLSQL | SOUNDEX Function
- PLSQL | ASCII Function
- PLSQL | CONCAT Function
- PLSQL | COMPOSE Function
- PLSQL | CHR Function
- PLSQL | ASCIISTR Function
- PLSQL | CONVERT Function
- PLSQL : || Operator
- PLSQL | DECOMPOSE Function
- PLSQL | DUMP Function
- PLSQL | INITCAP Function
- PLSQL | LENGTHC Function
- PLSQL | LENGTHB Function

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.