int countPositiveElements(int arr[], int size) { int count = 0; for (int i = 0; i < size; i++) { if (arr[i] > 0) { count++; } } return count; }
int main() { int arr[] = {1, -2, 3, -4, 5}; int size = sizeof(arr) / sizeof(arr[0]);
int positiveCount = countPositiveElements(arr, size); std::cout << "Number of positive elements in the array: " << positiveCount << std::endl; return 0;
int countPositiveElements(int arr[], int size) {
int count = 0;
for (int i = 0; i < size; i++) {
if (arr[i] > 0) {
count++;
}
}
return count;
}
int main() {
int positiveCount = countPositiveElements(arr, size);int arr[] = {1, -2, 3, -4, 5};
int size = sizeof(arr) / sizeof(arr[0]);
std::cout << "Number of positive elements in the array: " << positiveCount << std::endl;
return 0;
}