Program to Swap Two Variables without using Third Variable

PROGRAM TO SWAP TWO VARIABLES WITHOUT USING 3rd VARIABLE

SQL > ED SWAP.SQL

       DECLARE

           A NUMBER := &a;

           B number &b;

       BEGIN

           a:= a + b;

           b: = a - b;

           a: = a - b;

dbms_output.Put_line(‘a’= a ||  ‘b‘=b);

end;


output

Before Swapping

a=5
b=10

After Swapping

a =10  
b= 5 

Related

Oracle 2063281780177688414

Post a Comment

emo-but-icon

item