Answers for "pl/sql program to swap two numbers without using third variable"

SQL
0

pl/sql program to swap two numbers without using third variable

DECLARE 
    -- declare variable num1, num2  
    -- of datatype number 
    num1 NUMBER; 
    num2 NUMBER; 
BEGIN 
    num1 := 1000; 
  
    num2 := 2000; 
  
    -- print result before swapping 
    dbms_output.Put_line('Before'); 
  
    dbms_output.Put_line('num1 = ' 
                         || num1 
                         ||' num2 = ' 
                         || num2); 
  
    -- swapping of numbers num1 and num2 
    num1 := num1 + num2; 
  
    num2 := num1 - num2; 
  
    num1 := num1 - num2; 
  
    -- print result after swapping 
    dbms_output.Put_line('After'); 
  
    dbms_output.Put_line('num1 = ' 
                         || num1 
                         ||' num2 = ' 
                         || num2); 
END; 
-- Program End
Posted by: Guest on October-06-2021

Code answers related to "pl/sql program to swap two numbers without using third variable"

Code answers related to "SQL"

Browse Popular Code Answers by Language