Puzzle 3 | Hack the Planet! |
| #include <iostream> |
| |
| int getUserId() { return 1337; } |
| |
| void restrictedTask1() |
| { |
| int id = getUserId(); |
| if (id == 1337) { std::cout << "did task 1\n"; } |
| } |
| |
| void restrictedTask2() |
| { |
| int id; |
| if (id == 1337) { std::cout << "did task 2\n"; } |
| } |
| |
| int main() { |
| restrictedTask1(); |
| restrictedTask2(); |
| } |
Guess the Output | |
---|---|
Try to guess what the output is before moving to the next page. |
The program has undefined behavior! But it might display the following ...
Get C++ Brain Teasers now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.