Thursday 5 November 2015

PLSQL Program to check whether a number is armstrong or not

declare
n number(5);
temp number(5);
r number(3);
s number(5);
begin
n:=&n;
temp:=n;
s:=0;
while(n>0)
loop
r:=n mod 10;
s:= s + (r*r*r);
n:=floor(n/10);
end loop;
if(temp = s) then
dbms_output.put_line(temp ||' is a Armstrong no');
else
dbms_output.put_line(temp ||' is NOT a Armstrong no');
end if;
end;

No comments:

Post a Comment