Debugging Practice Each program has a bug. Fix it in the editor, run it in the real compiler, and get a plain explanation of what went wrong. Hints first; the solution unlocks after you try.
Stage 1: Absolute Beginner The missing piece Print Hello, C++! on one line. beginner Average is wrong Print the average of 7 and 8 as 7.5. beginner Stage 2: Conditions and Loops Everyone passes Print Fail for a mark of 30 (pass mark is 40). beginner Counting 1 to 5 Print 1 2 3 4 5 separated by spaces. beginner Stage 3: Functions and Modular Programming Swap doesn't swap Swap x and y, printing 2 1. intermediate Square of 6 Print 36. intermediate Stage 4: Arrays, Strings, and Data Handling Sum of an array Print the sum of {4, 5, 6}: 15. intermediate Count the vowels Count vowels in "programming": print 3. intermediate Stage 5: Pointers and Memory Pointer to nowhere Print 42 using a pointer. advanced Where did my size go? Print the number of elements, 5. advanced Stage 6: User-Defined Types and OOP Private balance Deposit 500 and print Balance: 500. intermediate Wrong shape speaks Print Circle through a Shape reference. advanced Stage 7: Files, Errors, and Debugging Catch the bad index Print Error caught instead of crashing. intermediate Random total Print the total of 1..4: 10. beginner Stage 8: Standard Template Library Remove the even numbers Remove evens from {1,2,4,5,6}, printing 1 5. advanced Phantom entries Print the map size 1 after checking for a missing key. intermediate Stage 9: Modern C++ Doubling does nothing Double every number, printing 2 4 6. intermediate Counter lambda Count calls; print 3. advanced Stage 10: Data Structures and Algorithms Binary search loops forever Find 9 in {1,3,5,7,9}: print index 4. advanced Factorial never stops Print 5! = 120. intermediate Want to experiment freely? Open the C++ compiler .