0
1.1kviews
WAP to calculate sum of series

½ + ¾ + 5/6 + …. + n terms.

Mumbai university > FE > SEM 2 > Structured Programming Approach

Marks: 6M

Year: May 2013

1 Answer
0
3views

Algorithm:

  • Start.

  • Declare variables i, j and Sum.

  • Read values of numbers.

  • Set i = 1 and j = 1.

  • Increment i and set j = j + 2.

  • Add numbers and assign the result to sum.

  • Sum = Sum + (float)(j)/(j+1).

  • Display sum.

  • Stop.

Program:

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

int main(){
int i, j, n;
float sum = 0;

printf("\n Enter the Value of n:");
scanf("%d",&n);

for(i=1, j=1; i<=n; i++, j=j+2){
sum = sum+(float)(j)/(j+1);
}
printf("sum= %f",sum);
}

Output:

Enter the Value of n: 5

Sum = 3.858333

Please log in to add an answer.