Page 4 - PROGRAMMING IN C_Neat
P. 4
Flow Chart:
Start
Input n
product = 1
False
for i = 1 to n
True
product = product * i
Output product
End
_______________________________________________________________________________________________
4. Write the algorithm and draw the flowchart to find the factorial of a given number. *
Note: This algorithm and flowchart is same as that of product of first n natural numbers.
Factorial of a Given Number:
n! = 1 * 2 * 3 … * n
Algorithm:
Begin
Input n
fact 1
for i 1 to n do
Begin
fact fact * i;
End
Output fact
End