**Prerequisite – PLSQL Introduction **

A PLSQL code is a groups of commands which are arranged within a block and block is a group of related declarations or statements.

Now, let us see a practical example of the area and perimeter of rectangle.

In declare part, we declare the list of variables and between begin and end part, we perform the operations.

**Area and Perimeter of Rectangle Explained **

What is the major difference between area and perimeter?

The area of region covered into the shape or figure whereas perimeter is the distance covered by periphery of the form .

The unit of area is given by square unit or unit2 and unit of perimeter is same because the entire area covered by a single unit.

In other words, area is that the term wont to define the quantity of space haunted by a 2D shape or surface. We usally define area in square units : cm² or m².

Area defined by multiplying the length of a shape by its total width.

Whereas perimeter is that the distance around the fringe of a shape to find out how to seek out the perimeter by adding up the side lengths of varied shapes.

**PLSQL Procedure **

**SQL> set serveroutput on
declare
L Number :=&Length;
W Number :=&Width;
P Number;
A Number;
Begin
P:=2*(L+W)
A:=L*W
dbms_output.put_line('Perimeter of Rectangle is '||P);
dbms_output.put_line('Area of Rectangle is '||A);
**
End;

**Output**

**Enter Value for Length: 4
Old 2: L Number :=&Length;
New 2: L Number :=4;
Enter Value for Width:5
Old 3: W Number :=&Width;
New 3: W Number :=5;
Perimeter Of Rectangle is 18
Area Of Rectangle is 20
PL/SQL Procedure Successfully Completed.**

**PLSQL Procedure Using Predefined Values**

Given the value of the length, breadth, and let us see how we can get the expected output.

**Examples**

Input: l = 5, b = 7

Output: Area = 35, Perimeter = 24

Input: l = 4, b = 8

Output: Area = 32, Perimeter=24

**Mathematical Calculation**

Area of rectangle is:

**Length * Breadth**

The perimeter of rectangle is:

**2 * ( Length + Breadth)**

Below is the necessary implementation.

`-`**- Declaration statement
DECLARE
-- This statement is used to declaration of length and assigning values
l NUMBER(4, 2) := 5;
--This statment is used to declaration of breadth and assigning values
b NUMBER(4, 2) := 7;
--This Statement is used to declaration of a variable for Area of rectangle
a NUMBER(4, 2);
--This statement is used to declaration of a variable for perimeter
p NUMBER(4, 2);
BEGIN
-- This statement is used to calculate area and perimeter
a := l * b;
p := 2 * (l + b);
--This statement is used to 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
**

**Here is Output**

The area of the given rectangle is 35

The perimeter of the given rectangle is 24

**Conclusion**

Here we’ve seen two methods one using parameters other one is passing static values.