Answer:
Explanation:
See attachment for the screen shot of the code.
//Sample Output
nter the numberof iterations4 The sum of the series is0.723810
//Code to copy
#include<stdio.h>
int main()
{
// Declare and initialize the Variables
int i, n;
int sign_flag = 1;
double sum = 0.0;
// Taking the number of iteration as input
printf("Enter the number of iterations ");
scanf("%d", &n);
// Sum upto n terms
// Sign flag is used for alternate positive and negative terms
for (i = 1; i <= n; i++)
{
sum = sum + sign_flag*(1.0 / (2 * i - 1));
sign_flag = -sign_flag;
}
// Print the sum
printf("The sum of the series is %lf\n", sum);
return 0;
}