PL SQL - sum of numbers from 1 to 100

-- This PL SQL program is used to find the sum of first 100 numbers.


declare
i number(10);
n number(10);
begin
n:=0;
i:=1;
while i<100
loop
n:=n+i;
i:=i+1;
end loop;
dbms_output.put_line('Sum is:'||n);
end;

Output
sum of first 100 PL SQL

2 comments:

Unknown said...

How I<100
It should be lessthale equal to 100

Nitin salunke said...

Don't use the while loop in the program to reduce the program length