Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int summary = 0;
- int N;
- cout << "Enter the amount of elements(N) = ";
- cin >> N;
- for (int i = 0; i < N; i++)
- {
- if (i % 2 == 0)
- summary += i + 1;
- else
- summary += (i + 1) * (-1);
- }
- cout << "Summary of N elements = " << summary;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement