Factorial of a number using recursion
#include<stdio.h>#include<conio.h>int fact(int);void main(){int n,f;clrscr();printf("Enter the limit");scanf("%d",&n);f=fact(n);printf("factorial is %d",f);getch();}int fact(int x){int p;if(x==0)return(1);else{p=x*fact(x-1);}return(p);}
0 Comments:
Post a Comment