C Program To Find Factorial Using Function | C programming

 C Program To Find Factorial Using Function

#include <stdio.h>

long int fact(int);

int main()

{

  int n;

  printf("Enter number: ");

  scanf("%d", &n);

  printf("%d!=%ld\n", n, fact(n));
}

long int fact(int n)

{

  if (n <= 1)

    return 1;

  else

    return (n * fact(n - 1));
}


Output

Factorial

Comments

Popular posts from this blog

C Program for SCAN Disk Scheduling Algorithm | C Programming

C program to Find Cartesian Product of Two Sets | C programming

C Program To Check The String Is Valid Identifier Or Not | C Programming