Getting a Wrong Answer (WA) on Codeforces doesn't always mean your algorithm is wrong. Sometimes, small implementation mistakes are the real problem.
Here are 6 common mistakes to watch out for when coding in C.
- Integer Overflow
Using "int" for values that exceed its range can produce incorrect results. Use "long long" when necessary.
- Wrong Format Specifiers
Match your format specifiers with the data types.
- "int" → "%d"
- "long long" → "%lld"
- "double" in "scanf()" → "%lf"
- Output Formatting
Extra spaces, missing newlines, or unnecessary messages can cause WA. Follow the exact output format.
- Integer Division
In C, "5 / 2" produces "2", not "2.5". Use floating-point arithmetic when decimals are required.
- Boundary Cases
Don't test only ordinary inputs. Check minimum values, maximum values, zero, and other special cases allowed by the constraints.
- Incorrect "scanf()" Usage
Remember the address operator ("&") when reading variables.
scanf("%d", &a); // Correct
Before Submitting
- Check constraints and data types.
- Verify format specifiers.
- Check output formatting.
- Test boundary cases.
- Double-check input statements.
Remember: A small bug can cause a Wrong Answer. Learn to identify the mistake, understand it, and avoid repeating it.
Happy coding!



