Pages

Adsense responsive

Tuesday, 5 February 2013

C PROGRAM: TO FIND FACTORIAL OF ANY NUMBER USING RECURSION

CODING:
#include<stdio.h>
#include<conio.h>
void main()
{
int rec(int),fact,x;
clrscr();
printf("Enter any number ");
scanf("%d",&x);
fact=rec(x);
printf("\n\nFactorial of %d = %d",x,fact);
getch();
}
int rec(int a)
{
int b;
if(a==1)
return(1);
else
b=a*rec(a-1);
return(b);
}


CODING

OUTPUT

For any query or suggestion please comment below...

No comments:

Post a Comment