Lab 9: Debug by adding print statements

In this week's lab, you will be given the code for Bubble Sort, however, there are some flaws in it. 

Please try to reveal and fix the flaws by adding output instructions to the code.

Here it how it works: 

1) first run the code, observe the output, and make some assumptions: what can be wrong? 

2) then, print out something to test your assumptions; 

3) make new assumptions and test again;

Show the instructions that you added, and explain your idea to the TA (you don't need to write down your assumptions).

Note: Ideally we should do it with the help of a debugger, but unfortunately, Codio's debugger for c/c++ is out of order right now, so we have to do it manually.

Step 1 (1 point)

Show that you know how to print out messages containing the variables that you think are problematic.

Step 2 (1 point)

Target the variable(s) and/or structure(s) that are actually causing problem.

Step 3 (1 point)

Correct the problematic variable(s) and/or structure(s) to fix the flaws.