Print and calculate the following series 1/2 + 2/3 + 3/4................+ 49/50

#include <iostream>
using namespace std;

void main ()
{
float deno=2;
float neu=1;
float sum=0;
float ans;

for (int i=1;i<50;i++)
{
ans=neu/deno;
sum=sum+ans; // add in the sum variable for display the sum of all the number
cout<<neu<<"/"<<deno<<"\t";

neu=neu+1;
deno=deno+1;
}
cout<<"\n\nThe sum of the series: "<<sum<<endl;
}

Comments

Popular posts from this blog

Umbrella activities in Software Engineering

Operating System | Best Definition of Opetating System