int main() { int A[10] = {1, -3, 5, -2, 4, -6, 7, -1, 9, -4}; int sum = 0; int count = 0;
for (int i = 0; i < 10; i++) { if (A[i] > 0) { sum += A[i]; count++; } } if (count > 0) { float average = (float)sum / count; std::cout << "Average of positive elements: " << average << std::endl; } else { std::cout << "No positive elements in the array." << std::endl; } return 0;
int main() {
for (int i = 0; i < 10; i++) {int A[10] = {1, -3, 5, -2, 4, -6, 7, -1, 9, -4};
int sum = 0;
int count = 0;
if (A[i] > 0) {
sum += A[i];
count++;
}
}
if (count > 0) {
float average = (float)sum / count;
std::cout << "Average of positive elements: " << average << std::endl;
} else {
std::cout << "No positive elements in the array." << std::endl;
}
return 0;
}