Programming Languages

PROGRAM TO FIND THE FACTORIAL OF A NUMBER USING RECURSION

/* PROGRAM TO FIND THE FACTORIAL OF A NUMBER USING RECURSION */

#include<stdio.h>
#include<conio.h>

int fact(int n);
void main()
{
int n,fac;
clrscr();
printf(“ENTER THE NUMBER : “);
scanf(“%d”,&n);
fac=fact(n);
printf(“THE FACTORIAL OF A NUMBER IS : %d”,fac);
getch();
}
int fact(int n)
{
int f;
if(n==1)
{
return 1;
}
else
{
return (n*fact(n-1));
}
}

ANIL VERMA
Hello Everyone, Welcome to A. V. Powertech.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.