PL/SQL Program for Reverse of a Number

Here you will get pl/sql program for reverse of a number.

For example:

Number = 34589

Reverse of number = 98543

 

PL/SQL Program for Reverse of a Number

declare
	n number;
	i number;
	rev number:=0;
	r number;

begin
	n:=&n;
	
	while n>0
	loop
		r:=mod(n,10);
		rev:=(rev*10)+r;
		n:=trunc(n/10);
	end loop;

	dbms_output.put_line('reverse is '||rev);

end;
/

 

Output

Enter value for n: 4578
old 8: n:=&n;
new 8: n:=4578;
reverse is 8754

Leave a Comment

Your email address will not be published. Required fields are marked *