Computer Science, asked by danisa86, 10 months ago

Write a program in c++ to calculate the sum of the following seriessum=1/2+2/3+3/4+.........+n/(n+1)

Answers

Answered by ramkaranbhatia1541
0

I have no answer regarding this

Answered by AskewTronics
0

Following are the program in c++ for the above question

Explanation:

#include <iostream>//header file.

using namespace std;

int main()//main function

{

   float N,i=1,j=2,sum=0; //variable declaration.

   cout<<"Enter the value of N "; //user message.

   cin>>N;//take the input.

    while(i<=N) //while loop.

    {

        sum=sum+(i/j); //doing the addition.

        i++; //for increse the numerator.

        j++;//for increate the denomenator.

    }

    cout<<sum; //print the sum.

   return 0;//return statement.

}

Output:

  • If the user inputs 1, it prints 0.5.
  • If the user inputs 3,it prints 1.91667.

Code Explanation:

  • The above program is written in c++ language which holds a while loop which runs in n time.
  • And there is a two-variable which is used for the numerator and denominator of the series.
  • The sum variable is used to add the sum and give the value.

Learn More:

  • C++ program: https://brainly.in/question/7087341
Similar questions