Showing posts with label Sum of n numbers. Show all posts
Showing posts with label Sum of n numbers. Show all posts

Monday, February 29, 2016

Sum of n numbers

set serveroutput on;
Declare
a number(4);
n number(4);
s number:=0;
Begin
n:=&n;
a:=1;
loop
s:=s+a;
exit when(a=n);
a:=a+1;
end loop;
dbms_output.put_line('Sum of n numbers = '||s);
end;
/