Search This Blog

Translate

C program to find the sum of following series


Write a C program to find the sum of following series.

#include"stdio.h"
#include"conio.h"

#include"math.h"
int fact(int n)
{
  int i,f = 1;
  for(i = 1; i <= n; i++)
     f *= I;
  return f;
}

void main()
{

float x,sum = 1,t;
int i,n, sign = -1;

printf("Enter n,x values\n");
scanf("%d%f",&n,&x);
sum = 0.0;
for(i = 1; i <= n; i++)
{
     sum += (pow(x,i)/fact(i));
            }
            printf(“The  e^x is %f”, sum);

}

C Program example List

Google+ Badge