Posts

Showing posts with the label c program to find factorial of a number using recursion

Basic Program #3

Image
3.Read any number and find factorial of a number. (Using Recursion) #include <stdio.h> long long int factorial(int n); int main() {     int n;    long long int f;     printf("Enter an integer to find it's factorial: ");     scanf("%d", &n);      // show error if the user enters a negative integer     if (n < 0)     {         printf("Error! Factorial of a negative number doesn't exist.\n");     }     else     {              f=factorial(n);             printf("Factorial of %d = %llu\n", n, f);     } } long long int factorial(int n) {     if (n>=1)     {         return n*factorial(n-1);  ...