#include using namespace std; void getAvgAndMax(int N, double &avg, int &max); int main() { double my_avg; int my_max; // Get avg and max of 5 integers from user getAvgAndMax(5, my_avg, my_max); cout << "Average was: " << my_avg << endl; cout << "Max was: " << my_max << endl; return 0; } // Get average and max of 5 numbers void getAvgAndMax(int N, double &avg, int &max) { cout << "Please enter " << N << " integers" << endl; // Get first number int val; cin >> val; // Starting values for max and sum max = val; int sum = val; // Get remaining numbers (N-1 of them) for (int i=0; i< N-1; i++) { cin >> val; sum += val; // Do we have a new max? if (val > max) { max = val; } } // Compute average. Since 'avg' is reference var, it will go back to main avg = double(sum) / N; }