Write a PL / SQL program for Factorial of a number - Computer Programming

Latest

C C++ Java Python Perl Programs Examples with Output -useful for Schools & College Students

Friday, September 29, 2017

Write a PL / SQL program for Factorial of a number

SQL Program For Factorial of a number

PROGRAM:


Declare 
num   number:= #
fact number:= 1;
temp number;
begin
  temp := num;
  while (num > 0)
  loop
    fact := fact * num;
  num   := num - 1;
  end loop;
 Dbms_Output.Put_line('factorial of ' || num ||'  is ' || fact);
end;

OUTPUT:
4
Factorial of 4 is 24

No comments:

Post a Comment