Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iomanip>
- #include<cmath>
- #include<iostream>
- using namespace std;
- int main()
- {
- double s=0;
- int x,i;
- cin>>x;
- for(i=1; i<=x; i++)
- {
- if(i%2!=0)
- s=s+sqrt(i);
- else
- s=s-sqrt(i);
- }
- cout<<setprecision(4)<<fixed<<s;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement