//////////////////////////////////////////////////////////////////////// // // hello.cpp // // This program illustrates a few elementary features of C++. // Note, for example, the global function and the lack of "new" // in the string declaration. At the same time, note the // similarity of the C++ loop and if/else syntax to that of Java. // // 1/3/03 (Jeff Ondich) Wrote it. // // //////////////////////////////////////////////////////////////////////// #include #include // A prototype for a global function. void report_parity( int n ); // The main program. int main() { int nGreetings; string name; cout << "What's your name? "; cin >> name; cout << "How many greetings do you desire? "; cin >> nGreetings; for( int i=0; i < nGreetings; i++ ) { cout << "Howdy, " << name << endl; } report_parity( nGreetings ); return 0; } // Reports to the user whether the given integer is even or odd. void report_parity( int n ) { if( n % 2 == 0 ) cout << "You asked for an even number of greetings." << endl; else cout << "You asked for an odd number of greetings." << endl; }