In 18

^{th}Lessons, it has been given an example to calculate the area of a circle. The formula to calculate the area of a circle is pr^{2}, where p is a constant with a value of 3:14 and r is the radius of the circle. The formula for calculating the circumference of a circle is 2pr^{2}. The following PL/SQL block to calculate area of a circle :**DECLARE**

**phi CONSTANT NUMBER := 3.14;**

**r NUMBER;**

**hasil NUMBER;**

**pilih VARCHAR2(1);**

**pilihan VARCHAR2(8);**

**BEGIN**

**r := &input_r;**

**pilih := '&luas_atau_keliling';--input L atau K**

**IF pilih = 'L' THEN**

**hasil := phi * r * r;**

**pilihan := 'Luas Lingkaran';**

**ELSE**

**hasil := 2 * phi * r;**

**pilihan := 'Keliling Lingkaran';**

**END IF;**

**DBMS_OUTPUT.PUT_LINE (pilihan||' = '||hasil);**

**END;**

**/**

Above PL/SQL
block will ask for 2 input values. The first input to fill the circle radius
(r) and the second input to determine the choice area or circumstance of circle
that will count. If the option on the input is L then will be loaded PL/SQL
block that will calculate the area of a circle, if the option is K then PL/SQL
block will calculate the circumference of a circle.

## 0 comments:

## Post a Comment