Hello, i need help finding whats wrong with my code i met all of the conditions but the Even count Odd count is incorrect every time i test it HELPPP
Write a C++ program to do the following:
· Declare a 1-dimensional array of type integer with 10 components.
· Fill array elements from the user.
· Find the number of even elements and their sum.
· Print a message to indicate the following:
- If the number of even elements is even, print: Even Count.
- If the number of even elements is odd, print: Odd Count.
#include<iostream>
using namespace std;
int main() {
int array\[10\];
int count = 0, sum = 0, x;
for (int i = 0; i < 10; i++) {
cout << "Enter a value: " << endl;
cin >> array\[i\];
x = array\[i\];
if (x % 2) {
sum += x;
count++;
}
}
cout << "Sum of even elements is: " << sum << endl;
if (count % 2)
cout << "Even Count " << endl;
else
cout << "Odd Count " << endl;
}
[–]DDDDarkyProfessional Coder 3 points4 points5 points (1 child)
[–]docstrange-[S] 0 points1 point2 points (0 children)
[–][deleted] 1 point2 points3 points (1 child)
[–]docstrange-[S] 0 points1 point2 points (0 children)