Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using namespace std;
- int main() {
- int n;
- cout << "enter number of elements\n"; cin >> n;
- vector<int> ar(n);
- for (int i = 0; i < n; ++i) cin >> ar[i];
- long long sum = 0;
- for (int i = 0; i < n; ++i)
- {
- if (ar[i] % 2 == 0)
- {
- sum += ar[i];
- printf("num: %12d| pos: %d\n", ar[i], i + 1);
- }
- }
- cout << "sum = " << sum;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement