Once in a while C++ programmer encounter “intelligence tests” which have the programmer examine some source code and make corrections or modifications to it. Here are a few challenges for you to try.

The code below is to write a dash “-” to the screen 40 times. You can replace, remove, or add one character in the code. Can you find 2 solutions?
```
int j, k = 40;
for( j = 0; j < k; --j)
cout << “-“;
```

```
There are two solutions to this puzzle. First, change the - - j to - - k
int j, k = 40;
for( j = 0; j < k; --k)
cout << "-";
The second solution is to add a negative sign to the j in the comparison statement
int j, k = 40;
for( j = 0; -j < k; --j)
cout << "-";
```

Computer Science & Information Technology

You might also like to view...

Which resource can be helpful when investigating older and unusual computing systems?

a. AICIS lists b. Uniform reports c. Forums and blogs d. Minix

Computer Science & Information Technology

Which of the following functions does the pasteboard provide?

A. Pasting B. Storing C. Transforming D. Measuring

Computer Science & Information Technology