Sum of 100 Numbers
declare
a number;
s number default 0;
begin
a:=1;
loop
s:=s+a;
exit when(a=100);
a:=a+1;
end loop;
dbms_output.put_line('Sum of 100 numbers = '||s);
end;
SQL> /
Sum of 100 numbers = 5050
declare
a number;
s number default 0;
begin
a:=1;
loop
s:=s+a;
exit when(a=100);
a:=a+1;
end loop;
dbms_output.put_line('Sum of 100 numbers = '||s);
end;
SQL> /
Sum of 100 numbers = 5050
No comments:
Post a Comment