// ThreeMap2.cc // Prints out values of a function 'threemap' #include using namespace std; int threemap (int n) { if (n%2) // n is odd return (3*n+1); else // n is even return (n/2) ; } void printout( int (*func)(int) , int xmin=1 , int xmax=100 ) { for ( int x = xmin ; x <= xmax ; x ++ ) { cout << x << " " << func( x ) << endl ; } } int main() { printout( threemap ) ; return 0; }