Assignment in Prog
Assignment in Prog
BSEE-1A
BEGIN
INPUT num1, num2, num3 // Get three numbers as input
BEGIN
INPUT n // Get a non-negative integer as input
IF n < 0 THEN
OUTPUT "Factorial is not defined for negative numbers"
ELSE IF n == 0 THEN
OUTPUT 1 // Factorial of 0 is 1
ELSE
factorial = 1
FOR i = 1 TO n DO
factorial = factorial * i
ENDFOR
OUTPUT factorial
ENDIF
END