google-site-verification: googlef8aa845b858144d3.html COMPUTER SCIENCE NOTES: FACTORIAL : (Example 2)

Monday, July 17, 2017

FACTORIAL : (Example 2)

/*find the factorial using funtion calling */
#include<stdio.h>
#include<conio.h>
long int fact(int);
void main()
{
int n;
long int a;
clrscr();
printf("Enter a number :");
scanf("%d",&n);
a=fact(n);
printf("factorial %ld ",a);
getch();


}
long int fact(int n)
{
if(n==0)
return (1);
else
return (n*fact(n-1));
}

No comments:

Post a Comment