Question

Write a c++ program to display the sum of following series using do while loop. 1/2+2/3+3/4+…..+99/100...


Write a c++ program to display the sum of following series using do while loop.

1/2+2/3+3/4+…..+99/100

 

 

Transcribed: iv. Write a program to display the sum of following series using do while loop. 1/2+2/3+3/4+..+99/100

Answer

// iostream in C++ is the standard library which implement stream based input/output capabilities

#include<iostream>

using namespace std;

int main()

{

    float n1=1, n2=2, sum=0;

    do

    {

        sum=sum+(n1/n2);

        n1+=1;

        n2+=1;

    }

    while(n1<=99);

    cout<<"The sum of the series is: "<<sum;

}

Recent Questions