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

Architecture of DBMS and RDBMS

DBMS AND RDBMS DBMS ARCHITECTURE: A data base is an organized collection of information. It consists of all the files in an organized manner therefore database is a structured and integrated s...

Features of SQL & SQL Plus

SQL:     SQL is, a common language for communicating with oracle server database to access the data. SQL is based on ASCII standards and SQL manipulates data and table definitions ...

RDBMS Keys & Constraints

There are two types of data constraints that can be applied to data inserted into a oracle table. There are I/O constraint [input/output] and business rule constraint. I/O CONSTRAINTS The inpu...

Post a Comment

emo-but-icon
:noprob:
:smile:
:shy:
:trope:
:sneered:
:happy:
:escort:
:rapt:
:love:
:heart:
:angry:
:hate:
:sad:
:sigh:
:disappointed:
:cry:
:fear:
:surprise:
:unbelieve:
:shit:
:like:
:dislike:
:clap:
:cuff:
:fist:
:ok:
:file:
:link:
:place:
:contact:

item