How to find area of circle using plsql program

Area of circle plsql program

In this article, we will see how to find Area of circle using plsql program for a given number. In a similar way, you can also find the Area and Perimeter Of Rectangle in PLSQL.

Area of a Circle

What is Circle:

A circle closed Aeroplan geometric shape. In specialized terms, a circle is a locus of a point moving around a fixed point at a fixed distance down from the point. Principally, a circle is an unrestricted wind with its external line equidistant from the centre.

The fixed distance from the point is the compass of the circle. In real life, you’ll get numerous exemplifications of the circle similar to a wheel, pizzas, an indirect ground, etc. Now let us learn, what are the terms used in the case of a circle.

Prerequisite – PL/SQL introduction

In PL/ SQL law groups of commands are arranged within a block. A block group related affirmations or statements. In declare part, we declare variables and between begin and end part, we perform the operations.

Here I have given the radius of a circle and the task is to find the area and perimeter of the circle.

Examples:

Input: 3
Output: Area = 28.26
        Perimeter = 18.84

Input: 7
Output: Area = 153.86
        Perimeter = 43.96

Formula for area and perimeter of circle:

Area:

pi * radius * radius

Perimeter:

2 * pi * radius

where pi = 3.14

Below is the required plsql program implementation:

--Find the area and perimeter of circle
DECLARE

	-- Variables to store area and perimeter
	area NUMBER(6, 2) ;
	perimeter NUMBER(6, 2) ;
	
	--Assigning the value of radius
	radius NUMBER(1) := 3;
	
	--Constant value of PI
	pi CONSTANT NUMBER(3, 2) := 3.14;
	
BEGIN

		--Formula for area and perimeter of a circle
		area := pi * radius * radius;
		perimeter := 2 * pi * radius;
		dbms_output.Put_line('Area = ' || area);
		dbms_output.Put_line(' Perimeter = ' || perimeter);

END;

You may also Like

Leave a comment