3 ms·
Use a pencil and paper. Make a column for each variable. As the values change, record the new value in a new row. That will get you through the test questions a
by Tangaroa 15y ago
Use a pencil and paper. Make a column for each variable. As the values change, record the new value in a new row. That will get you through the test questions as long as you read the code correctly.
Think about what could cause loops to behave in unexpected ways. Consider off-by-one loop errors like >= where > was needed and vice versa, or a loop condition being assignment (x=y where y is nonzero, so it resolves to true) instead of testing for equality (x == y). Write code for long enough and you will make these errors yourself and debug them so you will become very good at recognizing them. Also be aware of the break, continue, return, and finally keywords.