set serveroutput on declare N number(5); s number(5):=0; r number(5); d number(5); begin n:=&N; while N<>0 loop d:=mod(N,10); s:=s+r+d; end loop; dbms_output.put_line('sum of digits is-'||s); end; /
Logic is wrong because there is no quotient value in your program. see once, i think in s:=s+r+d; statement 'r' is not initialized. It is r:=(n/10); then only possible. Thank you.
Logic is wrong because there is no quotient value in your program. see once,
ReplyDeletei think in s:=s+r+d; statement 'r' is not initialized. It is r:=(n/10);
then only possible. Thank you.