OCJP

Factorial

#include<stdio.h>
#include<conio.h>
void main()
{
int n,i;
long fac=1;
float s,sum=0;
clrscr();
printf("\n enter the value of n:");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
fac*=i;
s=1.0/fac;

printf("\nFactorial of %d is %ld Step is %f ",i,fac,s);
sum+=s;

}
printf("\nSum %f",sum);
getch();
}

Leave a Reply

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


× How can I help you?