factorial of any number using recursion in c
c language mai recursion ka us krke kisi number ka factorial
#include<stdio.h> //header fileint fac(int); //function definition
void main() //main function
{int a,s; //main k under k variable
scanf("%d",&a); //input number by user
s=fac(a); // value assigned in s
printf("%d",s); //s ki final value jo factorial k baad niklegi
}
int fac(int x) //fac() function ka declaration
{ if(x==0)
return 1;
x=x*fac(x-1);
return x;
}
Comments
Post a Comment