This is a simple C++ program for beginners to find the
factorial of a number. The recursive function is used to find the factorial of
a number.
Source Code
#include<stdio.h> int fact(int n); int main() { int number,ans; printf("\n \n *************** FIND FACTORIAL ************** \n\n\n"); printf("Enter Number : "); scanf("%d",&number); ans=fact(number); printf("\n Factorial : %d \n \n",ans); return 0; } int fact(int n) { int f; if(n==1) return (1); else f=n*fact(n-1); return (f); }
0 comments:
Post a Comment