factorial-recursion

 #include <stdio.h>

int factorial(int a);
int main()
{

    int a = 5;
    printf("The factorial of %d is:%d\n", a, factorial(a));
    return 0;
}

int factorial(int x)
{

    if (x == 0 || x == 1)
    {
        return 1;
    }
    else
    {
        return x * factorial(x - 1);
    }
}

Comments

Popular posts from this blog

snake game Version-2 (using random number)

allocating dynamic memory using calloc

store a table in dynamic array and then change the size of array dynamically to store more numbers