Table Of Contents
Previous Section Next Section

Program 5: First Errors

Every novice programmer starts out learning about simple expressions and how to print them. But the following program is a little too simple. What's the problem?

  1 /************************************************
  2  * A program to answer the question of a five   *
  3  *      year old:                               *
  4  *              "What is 2 + 2?"                *
  5  ************************************************/
  6 #include <iostream>
  7
  8 int main()
  9 {
 10     int result; // Result of the addition
 11
 12     result = 2+2;
 13     std::cout << "The answer is " << result;
 14     return (0);
 15 }

(Next Hint 251. Answer 43.)

Table Of Contents
Previous Section Next Section