sahajjain01

Display the sum of this series: 1+1/2+1/3....1/n.

Aug 4th, 2013
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.27 KB | None | 0 0
  1. //Program to display the sum of this series: 1+1/2+1/3....1/n.
  2. #include<iostream.h>
  3. #include<conio.h>
  4. void main()
  5. {
  6.     clrscr();
  7.     float a,b=0,i;
  8.     cout<<"Enter a number: ";
  9.     cin>>a;
  10.     for(i=1;i<=a;i++)
  11.     b=b+(1/i);
  12.     cout<<"The sum of the series is: "<<b;
  13.     getch();
  14. }
Advertisement
Add Comment
Please, Sign In to add comment