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

C program to find factorial using function
Share To:

Arogya Thapa Magar

Post A Comment:

0 comments so far,add yours