PROGRAM TO FIND FACTORIAL OF A NUMBER AND USE RETURN STATEMENT IN FUNCTION


LIST OF PROGRAMS

#include<stdio.h>
#include<conio.h>
long int f=1,j,a;
void main()
{
long int fact(long int a);
clrscr();
printf("enter the number");
scanf("%ld",&a);
f=fact(a);
printf("\nFACTORIAL IS:%ld",f);
getch();
}
long int fact(long int a)
{
for(j=2;j<=a;j++)
f=f*j;
return f;
}

Comments