SQL program for finding factorial for given 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 up to c and                                   store in a
Step 5: display the value of a as result
Step 6 : Stop the program
 


PROGRAM:
  
SQL>set server output on
SQL>declare
a number (5):=1;
b number (5):=1;
c number (5):=;
begin
c:=&c;
for b in 1.. c loop
a:a*b;
end loop;
dbms_output.put_line (a);
end;

OUTPUT:                      

Enter the value for c:5
Old 6:c=&c;
New 6:c:=5;
120

0 comments:

Post a Comment