Write a Program for printing Factorial of a number in given range

#include<stdio.h> #include<conio.h> into fact ( int x); main ( ) { int i, n; printf (“enter how many factors”); ...

#include<stdio.h>
#include<conio.h>
into fact ( int x);
main ( )
{
int i, n;
printf (“enter how many factors”);
scanf ("%d”, &n);
for ( i =0; i < n; i ++)
{
  printf (“factorial of %d is %d \n",i, fact (i));
}
getch ( );
}

int fact ( int x)
{
int s = 1, i;
for ( i =1; i < =x; i ++)
{
  s =s*i ;
}
return ( s);
}

Out put:

Enter how many factor 5
Factorial of 0 is 1
Factorial of 1 is 1
Factorial of 2 is 2
Factorial of 3 is 6
Factorial of 4 is 24
Factorial of 5 is 120

Related

C Programs 3381692306547685629

Post a Comment

emo-but-icon

item