Pages

Ads 468x60px

Sunday, 3 June 2012

PL SQL Program For to check the given number is armstrong or not.


PL SQL Program For to check the given number is armstrong or not. 


declare
n number(3);
s number(3):=0;
t number(3);
begin
n:=&n;
t:=n;
while t>0 loop
s:=s+power((t mod 10),3);
t:=trunc(t/10);
end loop;
if(s=n) then
dbms_output.put_line('The given number ' || n || 'is an armstrong number');
else
dbms_output.put_line('The given number ' || n || 'is not an armstrong number'); 
end if;
end;

0 comments:

Post a Comment

Total Pageviews