**1+x+(x2/2!)+(x3/3!)+………………………………………+(x^n/n!) Write a program to show the sum of he series when x & n is input through the keyboard.**

#include<stdio.h>

#include<math.h>

#include<math.h>

void main()

{

int x,n,i,j,fact;

float sum=1;

clrscr();

printf("\nEnter the Value of 'x' : ");

scanf("%d",&x);

printf("\nEnter the value of 'n' : ");

scanf("%d",&n);

for(i=1;i<=n;i++)

{

fact=1;

for(j=1;j<=i;j++)

{

fact*=j;

}

sum=sum+(pow(x,i)/fact);

}

printf("\nSum of the Series : %5.2f",sum);

getch();

}

{

int x,n,i,j,fact;

float sum=1;

clrscr();

printf("\nEnter the Value of 'x' : ");

scanf("%d",&x);

printf("\nEnter the value of 'n' : ");

scanf("%d",&n);

for(i=1;i<=n;i++)

{

fact=1;

for(j=1;j<=i;j++)

{

fact*=j;

}

sum=sum+(pow(x,i)/fact);

}

printf("\nSum of the Series : %5.2f",sum);

getch();

}

==============

# C program for the series: 1+x+x^2/2+x^3/3+.....+x^n/n?

include<math.h>

int i, x, n;

int sum = 1;

//get n from user

for(i = 1; i < n; i++)

{

sum += pow(i, x)/x;

}

return sum;

int i, x, n;

int sum = 1;

//get n from user

for(i = 1; i < n; i++)

{

sum += pow(i, x)/x;

}

return sum;

## No comments:

## Post a Comment