Follow by Email

बुधवार, 30 जनवरी 2019

find factorial of any number using recursion in c

factorial of any number using recursion in c

c language mai recursion ka us krke kisi number ka factorial 

#include<stdio.h>           //header file
int 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;
}
NEXT ARTICLE Next Post
PREVIOUS ARTICLE Previous Post
NEXT ARTICLE Next Post
PREVIOUS ARTICLE Previous Post
 

best and cheap hosting

Delivered by FeedBurner