Write a program to input the value of x and n and print the sum of the following series L 1 + x + x2 + x3 + x4 + X5 1-x+x²-x3+x4 -85 YN *-+*+ X- XN Determine whether a number in + 2 3 N
Attachments:
Answers
Answered by
0
Answer:
Explanation:
#include <stdio.h>
#include <math.h>
int main()
{
int sum =1, x, n, i;
printf("Here we will calculate the sum of series 1+ x + x^2+ ...+ x^n \n");
printf("Enter the value of x: ");
scanf("%d", &x);
printf("Enter the value of n: ");
scanf("%d", &n);
for(i=1; i<=n;i++)
{
sum+=pow(x,i);
}
printf("The sum of the series is: %d", sum);
return 0;
}
Similar questions