Practical Practice 14

Oracle Practice

Write a program to enter base and height of a triangle and find its area in PLSQL block.

Write a program to enter base and height of a triangle and find its area in PLSQL block.

SOLUTION

--Static code

 set serveroutput on;
DECLARE
   base_triangle NUMBER := 10 ; 
   height_triangle NUMBER := 5; 
   area_triangle NUMBER; 
BEGIN
      area_triangle := (base_triangle * height_triangle) / 2;
      DBMS_OUTPUT.PUT_LINE('The area of the triangle is ' || area_triangle);  
END;
    


--Dynamic code 
set serveroutput on;
DECLARE
   base_triangle NUMBER := &base_triangle ; 
   height_triangle NUMBER := &height_triangle; 
   area_triangle NUMBER; 
BEGIN
      area_triangle := (base_triangle * height_triangle) / 2;
      DBMS_OUTPUT.PUT_LINE('The area of the triangle is ' || area_triangle);  
END;
/

TRY IT YOURSELF

Leave a Reply

Your email address will not be published. Required fields are marked *

sign up!

We’ll send you the hottest deals straight to your inbox so you’re always in on the best-kept software secrets.