Advertisement
SelinD

ex88pg63

Apr 9th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.30 KB | None | 0 0
  1. #include<iomanip>
  2. #include<cmath>
  3. #include<iostream>
  4. using namespace std;
  5. int main()
  6. {
  7. double s=0;
  8. int x,i;
  9. cin>>x;
  10. for(i=1; i<=x; i++)
  11. {
  12. if(i%2!=0)
  13. s=s+sqrt(i);
  14. else
  15. s=s-sqrt(i);
  16. }
  17. cout<<setprecision(4)<<fixed<<s;
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement