C++ Program to display the sum of this series: 1+1/2+1/3....1/n.

C++ Program to display the sum of this series: 1+1/2+1/3....1/n.



#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
float a,b=0,i;
cout<<"Enter a number: ";
cin>>a;
for(i=1;i<=a;i++)
b=b+(1/i);
cout<<"The sum of the series is: "<<b;
getch();
}


Learn More :