Write a program in PL/SQL to print the reverse of a number.
According to the problem if a number is 677 then it should print 776.
Program Code:
SQL> set serveroutput on
SQL>Declare
2 num number:=&n;
3 rev number:=0;
4 Begin
5 while(num>0)
6 Loop
7 rev:=rev*10+mod(num,10);
8 num:=num/10;
9 End loop;
10 Dbms_Output.Put_Line('Reverse of number is '|| rev);
11 End;
12 /
Thanks.
According to the problem if a number is 677 then it should print 776.
Program Code:
SQL> set serveroutput on
SQL>Declare
2 num number:=&n;
3 rev number:=0;
4 Begin
5 while(num>0)
6 Loop
7 rev:=rev*10+mod(num,10);
8 num:=num/10;
9 End loop;
10 Dbms_Output.Put_Line('Reverse of number is '|| rev);
11 End;
12 /
Thanks.
No comments:
Post a Comment