Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Tinh S(n) = 1/2 + 2/3 + 3/4 + ... + n/(n+1)
- // Khai bao thu vien
- #include<stdio.h>
- #include<conio.h>
- void main()
- {
- // khai bao bien
- int n;
- // nhap du lieu
- scanf("%d",&n);
- float s=0;
- for(int i=1;i<=n;i++)
- {
- s=s+ (float) i/(i+1);
- }
- printf("%.2f",s);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement