codemaniacstudio

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

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

Exit mobile version