Skip to main content

FACTORIAL USING RECURSION


LIST OF PROGRAMS


#include<stdio.h>
#include<conio.h>
void main()
{
int fact(int n2);
int f,n;
clrscr();
printf("ENTER A NUMBER");
scanf("%d",&n);
f=fact(n);
printf("FACTORIAL %d",f);
getch();
}
int fact(int n2)
{
if(n2<0)
return(0);
else if (n2==0||n2==1)
return(1);
else
return(n2*fact(n2-1));
}

Comments

Popular posts from this blog

unix commands