Write a program in C++ that inputs and stores 10 numbers in an array and prints the sum and average of the array elements?
#include <iostream>
using namespace std;
int main() {
int numArray[10];
int sum = 0;
double avg;
// Input numbers into array
for (int i = 0; i < 10; i++) {
cout << "Enter number " << i+1 << ": ";
cin >> numArray[i];
sum += numArray[i];
}
// Calculate average
avg = static_cast<double>(sum) / 10;
// Print sum and average
cout << "Sum of array elements = " << sum << endl;
cout << "Average of array elements = " << avg << endl;
return 0;
}