write a program to find the sum of the following series x+x2+x3+x4 ........x10,5+10+15+20..........100
Answers
Answered by
2
Answer:
// C program to get the sum of the series
#include <math.h>
#include <stdio.h>
// Function to get the series
double Series(double x, int n)
{
double sum = 1, term = 1, fct, j, y = 2, m;
// Sum of n-1 terms starting from 2nd term
int i;
for (i = 1; i < n; i++) {
fct = 1;
for (j = 1; j <= y; j++) {
fct = fct * j;
}
term = term * (-1);
m = term * pow(x, y) / fct;
sum = sum + m;
y += 2;
}
return sum;
}
// Driver Code
int main()
{
double x = 9;
int n = 10;
printf("%.4f", Series(x, n));
return 0;
}
Similar questions