Skip to main content

Practice · 3 of 5

Debug: The Shrinking Product

CHALLENGE
Difficulty: intermediate+25 XP

**Description:** The program must print a[0] * a[1] (values up to 10^5), but sometimes prints nonsense. Find and fix the bug. **Broken code:** ``cpp void solve(std::istream& in, std::ostream& out) { int a, b; in >> a >> b; int p = a * b; out << p; } ` **Input:** One line: a b (|a|, |b| <= 100000). **Output:** One integer — the product. **Example:** 300 400 -> 120000`.

Back to lesson: Practice: Debugging Problem Set