This program computes the area of a triangle. The formula is simple, the program is simple, and it's clear that everything works. But there is a surprise lurking within this code:
1 /************************************************
2 * triangle -- Compute the area of a triangle *
3 ************************************************/
4 #include <iostream>
5 int main()
6 {
7 int base = 0; /* Base of the triangle */
8 int height = 0; /* Height of the triangle */
9
10 base = 5; /* Set the base of the triangle
11 height = 2; /* Set the height */
12
13 // Area of the triangle
14 int area = (base * height) / 2;
15
16 std::cout << "The area is " <<
17 area << std::endl;
18 return (0);
19 }