Write a PL/SQL block to find the sum of first 100 odd nos. and even nos). PL/SQL Program to find the sum of first 100 odd nos. and even nos
declare
odd number:=0;
even number:=0;
i number;
begin
for i in 1..100
loop
if(i mod 2 = 0) then
even:=even+i;
else
odd:=odd+i;
end if;
end loop;
dbms_output.put_line('The Sum of 100 even nos is ' || even);
dbms_output.put_line('The Sum of 100 odd nos is ' || odd);
end;
No comments:
Post a Comment