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
0
I have no answer regarding this
Answered by
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
Computer Science,
5 months ago
Hindi,
5 months ago
Math,
10 months ago
Math,
10 months ago
Science,
1 year ago