Table Of Contents
Previous Section Next Section

Program 25: Maximum Surprise

The loop in this program is designed to print a greeting ten times. But the program has different ideas. So what happens?

Note 

This program fails to compile on the GNU compilers and other systems that do not implement preprocessor directives exactly as the standard calls for. (They do a better job, which unfortunately breaks this program.)

  1 /************************************************
  2  * Print a bunch of greetings.                  *
  3  ************************************************/
  4 #include <iostream>
  5
  6 #define MAX =10
  7
  8 int main()
  9 {
 10     int counter;        // Current greeting
 11
 12     for (counter =MAX; counter > 0; --counter)
 13         std::cout <<"Hi there\n";
 14
 15     return (0);
 16 }

(Next Hint 194. Answer 112.)

Table Of Contents
Previous Section Next Section