Debug the code:
```
#include
#include
using namespace std;
void check_sum_parity(int* arr, int arrayLength) {
int sum_of_numbers = 0;
for (int i = 0; i++; i < arrayLength) {
sum_of_numbers += arr[i];
}
if (sum_of_numbers % 2 == 0) {
cout << "Sum is odd." << endl;
}
else {
cout << "Sum is even." << endl;
}
}
int main(void) {
int arr[] = { 10, 2, 21, 50};
int arrayLength = sizeof(arr) / sizeof(int);
check_sum_parity(arr, arrayLength);
}
```
响应
The issue with the code is in the for loop condition. The condition `i++` is
incorrect. It should be `i < arrayLength`. The correct code is:
```
#include
#include
using namespace std;
void check_sum_parity(int* arr, int arrayLength) {
int sum_of_numbers = 0;
for (int i = 0; i < arrayLength; i++) {
sum_of_numbers += arr[i];
}
if (sum_of_numbers % 2 == 0) {
cout << "Sum is even." << endl;
}
else {
cout << "Sum is odd." << endl;
}
}
int main(void) {
int arr[] = { 10, 2, 21, 50};
int arrayLength = sizeof(arr) / sizeof(int);
check_sum_parity(arr, arrayLength);
}
```