/* func2.cpp */ #include using namespace std; // Prototypes int CharToDigit( char ch ); int IsEven( int n ); int main() { char c; int result; // numeric value of c cout << "Enter a digit (char): " << flush; cin >> c; cout << "c: " << c << endl; result = CharToDigit( c ); cout << "numeric value: " << result << endl; if( IsEven(result) ) cout << "even" << endl; else cout << "odd" << endl; return 0; } int CharToDigit( char ch ) { int n; // result n = ch - '0'; return n; } int IsEven( int n ) { int retVal = 1; // assume true if( n % 2 ) // odd { retVal = 0; } /* version 2 int result; result = n % 2; if( result ) // odd { retVal = 0; } */ /* version 1 if( result ) // odd retVal = 0; else retVal = 1; */ return retVal; }