Practical Practice 12

Oracle Practice

Write a program to enter any number and calculate its square root in PLSQL block.

Write a program to enter any number and calculate its square root in PLSQL block.

SOLUTION

--Static code

DECLARE
   num NUMBER := 25;      
   sqrt_result NUMBER; 
BEGIN
      sqrt_result := SQRT(num);
      DBMS_OUTPUT.PUT_LINE('Square root of ' || num || ' is ' || sqrt_result);
END;
/
    


--Dynamic code 
DECLARE
   num NUMBER := #      
   sqrt_result NUMBER; 
BEGIN
      sqrt_result := SQRT(num);
      DBMS_OUTPUT.PUT_LINE('Square root of ' || num || ' is ' || sqrt_result);
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.