Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- long n,E=0,i=1;
- int p=-1;
- cout<<"n=";cin>>n;
- while (i<=n)
- {
- p*=-1;
- E+=p*(2*i);
- i++;
- }
- cout<<"E="<<E;
- return 0;}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement