You are on page 1of 5

LAB MST

NAME – SANT PRASAD PATHAK


UID – 20BET1103

Q-1 Write a PL/SQL program to SWAP two numbers with and


without using temporary variables.

SOURCE CODE -

Using Temporary Variable

declare
a number;
b number;
temp number;

begin
a:=30;
b:=20;

dbms_output.put_line('Before swapping the number are :');


dbms_output.put_line('a='||a||' b='||b);

temp:=a;
a:=b;
b:=temp;

dbms_output.put_line('After swapping the number are :');


dbms_output.put_line('a='||a||' b='||b);

end;
/

SCREENSHOT -

OUTPUT –
Without Using Temporary Variable

declare
a number;
b number;

begin
a:=30;
b:=20;

dbms_output.put_line('Before swapping the number :');


dbms_output.put_line('a='||a||' b='||b);

a:=a+b;
b:=a-b;
a:=a-b;

dbms_output.put_line('After swapping the number:');


dbms_output.put_line('a='||a||' b='||b);

end;
/

SCREENSHOT –
OUTPUT-

You might also like