Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Selected Reading
Find the area and perimeter of right triangle in PL/SQL
In this problem, we are given three values: base, height and hypotenuse of a right triangle. Our task is to find the area and perimeter of the right triangle in PL/SQL.
PL/SQL is a combination of SQL along with the procedural features of programming languages
Let's take an example to understand the problem,
Input : height = 4, base = 3, hypotenuse = 5 Output : area = 6, perimeter = 12
Explanation −
1 + 22 + 333 + 4444 = 4800
Solution Approach
A simple approach to solve the problem is using the formula for the area and perimeter of the triangle.
Area = 1/2*(height)*(base)
Perimeter = (height) + (base) + (hypotenuse)
Example
Program to illustrate the working of our solution in PL/SQL
DECLARE
hypotenuse FLOAT;
base FLOAT;
height FLOAT;
area FLOAT;
perimeter FLOAT;
BEGIN
hypotenuse := 13;
base := 5;
height := 12;
area := (1/2)* base * height;
perimeter := hypotenuse + height + base; dbms_output.Put_line('The Perimeter of triangle is ' || perimeter);
dbms_output.Put_line('The Area of triangle is ' || area);
END;
Output
The Perimeter of triangle is 30 The area of triangle is 30
Advertisements
