Write a PL / SQL Program to check Armstrong Number or Not - Computer Programming

Latest

C C++ Java Python Perl Programs Examples with Output -useful for Schools & College Students

Friday, September 29, 2017

Write a PL / SQL Program to check Armstrong Number or Not

SQL Program to Check ARMSTRONG NUMBER


PROGRAM:

declare
  num number;
  tot number:=0;
  var1 number;
  var2 number;
begin
  num:=#
  tmp:=num;
  while tmp>0
  loop
    var1:=tmp mod 10;
    tot:= tot + (var1*var1*var1);
    tmp:=tmp/10;
  end loop;
  if(tot==num) then
    dbms_output.put_line(num||' is armstrong no');
  else
    dbms_output.put_line(num||' is not a armstrong no');
  end if
end;

OUTPUT:

153
153 is armstrong no

No comments:

Post a Comment