Write a program to find factorial of given number using recursive function in c program .
Solution :
#include<stdio.h>
#include<conio.h>
int fact(int);
void main(){
int n,f;
printf("Enter no. for finding factorial");
scanf("%d",&n);
f=fact(n);
printf("factorial is %d",f);
getch();
}
int fact(int n){
if(n==0){
return(1);
}
else{
return(n*fact(n-1));
}
}
OUTPUT :
This question is also one of the most important questions of c program for class 11 and 12 computer science . Further more questions and solutions visit our blog
https://tukustech.blogspot.com/
No comments:
Post a Comment