PL/SQL PROGRAM SUM OF N NUMBERS
AIM:
To
write a program to create functions for finding the sum of n-numbers
ALGORITHM:
Step 1: Start the program
Step
2: declare the variables
Step 3 : initialize a=0 and b=1
Step 4 : get the value of a and b
by incrementing value of b upto c and store in a
Step 5: display
the value of a as result
Step 6 : Stop the program
PROGRAM:
SQL> set serveroutput on
SQL> declare
2 a number (5)=0;
3 b number (5);
4 c number (5);
5 begin
6 c:=&c;
7 for b in 1...c loop
8 a:=a+b;
9 end loop;
10 dbms_output.put_line(a);
11 end ;
12 /
Enter value for c:
12
old 6: c:=&c;
new 6: c:=12;
78
Pl/sql procedure successfully complet
0 comments:
Post a Comment