You are on page 1of 1

#include <stdio.

h> int factorial (int n) { int factorial = 1 ; printf ( "Enter the value of n:") ; scanf ( "%d" , & n ) ; while ( n != 0 ) { factorial *= n ; n--; } printf ( "The factorial of n is\n%d\n" , factorial ) ; return 0; } int main() { int n; if(n==0) return 1; if else (n<0) printf("Program terminated."); else return factorial(n); }

You might also like