for eg factorial of 5=5*4*3*2*1 <br />
the source code of the program is :<br />
<br />
<br />
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
#include<conio.h> | |
int factorial(int); | |
void main() | |
{ | |
int num; | |
printf("enter the number whose factorial is to be find"); | |
scanf("%d",&num); | |
fact=factorial(num); | |
printf("the factorial of the input num is %d",fact); | |
getch(); | |
} | |
int factorial(int n) | |
{ | |
if(n==0) | |
return (1); | |
else | |
return(n*fact(n-1); | |
} | |
0 comments :
Post a Comment