Functional Average II
using namespace std;
double av(int n1, int n2, int n3)
sum = n1 + n2 + n3;
return sum / 3.0;
void print_it(int a1, int a2, int a3, double av)
cout << "The average of " << a1 << " " << a2 << " " << a3
<< " is " << av << endl;
int n1, n2, n3;
cout << "Enter: ";
cin >> n1 >> n2 >> n3;
print_it(n1, n2, n3, av(n1, n2, n3));
As in Java, the return type of void means
there is nothing to return.
Some languages distinguish functions (with return values) and
procedures (without). A much more rational arrangement.
We have C to thank for void.
This code both C and C++.