PL/SQL Program to Calculate Sum of Digit

PL/SQL Program to Calculate Sum of Digit:



declare
sod number;
no number;
len number;
digit number;
begin
digit:=0;
sod:=0;
no:=:no;
len:=length(no);
for i in 1..len
loop
digit:=substr(no,i,1);
sod:=sod+digit;
end loop;
dbms_output.put_line('Entered Number is : '||no);
dbms_output.put_line('Sum of Digit : '||sod);
end;

OUTPUT:

Entered Number is : 1532
Sum of Digit : 11

Leave a Reply

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

seventeen − 17 =

This site uses Akismet to reduce spam. Learn how your comment data is processed.