Showing posts with label factorial of a number. Show all posts
Showing posts with label factorial of a number. Show all posts

Tuesday, 22 September 2020

C Program to find the factorial of a number using Recursion

September 22, 2020 Posted by Knowledge Bite , , , 1 comment
#include <stdio.h> long factorial(int n) { if (n == 0) return 1; else return(n * factorial(n-1)); } void main() { int number; long fact; printf("Enter a Number: "); scanf("%d", &number); fact = factorial(number); printf("Factorial of %d is %ld\n", number, fact); getch(); } ...