Write a function to calculate the factorial value of any integer entered through the keyboard.
N.B. It will work up to nineteen number.
#include <stdio.h>
#include <conio.h>
long fact ( int ); /* Function prototype declaration */
void main ( )
{
int no;
long factorial;
clrscr ( );
printf("\n\n\t\t Enter a number...:"); scanf("%d", &no);
factorial = fact ( no ); /* Function calling */
printf("\n\n\t\t FACTORIAL OF %d = % ld", no, factorial);
getch ( );
}
long fact ( int j ) /* Function Definition */
{
int i;
long f = 1;
for ( i = 1; i <= j; i++ )
{
f = f * i;
}
return ( f );
}
Click here to contact us
N.B. It will work up to nineteen number.
#include <stdio.h>
#include <conio.h>
long fact ( int ); /* Function prototype declaration */
void main ( )
{
int no;
long factorial;
clrscr ( );
printf("\n\n\t\t Enter a number...:"); scanf("%d", &no);
factorial = fact ( no ); /* Function calling */
printf("\n\n\t\t FACTORIAL OF %d = % ld", no, factorial);
getch ( );
}
long fact ( int j ) /* Function Definition */
{
int i;
long f = 1;
for ( i = 1; i <= j; i++ )
{
f = f * i;
}
return ( f );
}
Click here to contact us
No comments:
Post a Comment