Two-Function Average
#include <iostream> using namespace std; /* This function takes three integers and returns their average value as a double. */ double average(int v1, int v2, int v3) { double sum; sum = v1 + v2 + v3; 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)); }