Wednesday, February 11, 2015

C program to find the sum of the series x x 2 2 x 3 3 x n n

C program to find the sum of the series x+x^2/2+x^3/3+.....+x^n/n

#include<stdio.h>
#include<conio.h>
#include<math.h>

void main()
{
int i,n;
float x,sum=0;
clrscr(); //to clear the screen

printf("x+x^2/2+x^3/3+.....+x^n/n");
printf("
Enter value of x and n:");

scanf("%f%d",&x,&n);

for(i=1;i<=n;++i)
sum+=pow(x,i)/i;

printf("
sum=%f",sum);

getch(); //to stop the screen
}

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.