# Area and Perimeter of Rectangle 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 value of the length, breadth, and the task is to calculate the area and perimeter of the Rectangle.

Examples:

```Input: l = 2, b = 2
Output: Area = 4, Perimeter = 8

Input: l = 4, b = 8
Output: Area = 32, Perimeter=24
```

Mathematical Formula:
Area of rectangle: Perimeter of rectangle: Below is the required implementation:

 `-- Declaration statement  ` `DECLARE` `  ``-- Declaration of length and assigning values  ` `  ``l NUMBER(4, 2) := 3;  ` `  ``--Declaration of breadth and assigning values  ` `  ``b NUMBER(4, 2) := 7;  ` `  ``--Declaration of a variable for Area of rectangle  ` `  ``a NUMBER(4, 2);  ` ` `  `  ``--Declaration of a variable for perimeter  ` `  ``p NUMBER(4, 2);  ` `BEGIN`  `   `  `  ``-- calculate area and perimeter ` `  ``a := l * b;  ` `  ``p := 2 * (l + b);  ` ` `  `  ``--Display result  ` `  ``dbms_output.Put_line(``'Area of the rectangle is  '`  `  ``|| a);  ` `  ``dbms_output.Put_line(``'Perimeter of the rectangle is '`  `  ``|| p);  ` `END``;  ` `--ENd program `

Output:

```Area of the rectangle is 21
Perimeter of the rectangle is 20
```

My Personal Notes arrow_drop_up Check out this Author's contributed articles.

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.

Article Tags :
Practice Tags :

1

Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.