OCJP

Factorial Using Function

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

int aj(int);
void main()
{
int x,f;
clrscr();
    printf("\nenter the value:");
    scanf("%d",&x);
   f=aj(x);
   printf("\nfactorial=%d",f);
getch();
}

int aj(int n)
{
int fac=1,i;
for(i=1;i<=n;i++)
{
fac*=i;
}
return fac;
}

Output

Leave a Reply

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


× How can I help you?