Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //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();
- }
Advertisement
Add Comment
Please, Sign In to add comment