Two-Function Average
#include <iostream> using namespace std; /* This function takes three integers and returns their average value as a double. */ double average(int n1, int n2, int n3) { double sum; sum = n1 + n2 + n3; return sum / 3.0; } /* This function simply prints the numbers averaged, and the result. */ void print_it(int a1, int a2, int a3, double av) { cout << "The average of " << a1 << " " << a2 << " " << a3 << " is " << av << endl; } int main(void) { // Prompt for, and read, three integers. cout << "Please enter three integer values: "; int n1, n2, n3; cin >> n1 >> n2 >> n3; print_it(n1, n2, n3, average(n1, n2, n3)); }