The last chapter ended with Java's library and what it prints. The papers love the opposite job just as much. You turn a page and there are ten lines of C, a gap, and one instruction: find the output. No computer, no compiler, a few marks, and the candidate next to you has already moved on. She is not cleverer than you. She has seen these questions often enough to know where they hide their traps, and she hears them coming.
A trap in an output question is never exotic. It is almost always an ordinary thing that the machine does by its own rules while you calculate by habit: a printf that quietly returns a number, a space that nobody printed, a comparison that doesn't mean what it means in maths, an = where you read ==. Almost every trap in this chapter comes straight from real bank and BCS papers.
By the end of the chapter you'll be able to trace a short program on paper with a method that doesn't depend on luck. You'll say exactly what printf prints and what it returns, read a format string such as %3d or %-5.1f, and tell what scanf stores and returns. You'll bracket any expression with the precedence ladder, work out integer division, mixed types, casts and sizeof, spot an assignment hiding in a condition, and follow ?:, &&, || and loops inside loops. And for every trap you'll know something the answer key rarely tells you: whether the C language itself promises that answer, or whether the answer is only what one compiler happens to do.
We'll go in three parts, easy to hard: input and output (traps 1 to 8), operators and numbers (traps 9 to 13), and conditions with nested loops (traps 14 to 17). Part 2 of Predict the output goes on with ++ and --, the comma operator and undefined behaviour; part 3 with sizeof, macros, strings and pointers.