All Flashcards
Why is code tracing important?
It helps understand program logic, develop debugging skills, and succeed on exams.
What is the purpose of the loop condition?
To determine whether the loop should continue executing or terminate.
Why is it important to update variables in a while loop?
To avoid infinite loops by ensuring the loop condition eventually becomes false.
What is the flow of control in nested loops?
The inner loop completes all its iterations for each iteration of the outer loop.
What is the first step in code tracing?
Start at the beginning of the code.
What is the relationship between code tracing and debugging?
Code tracing is a fundamental skill for identifying and fixing errors in code.
What is the role of the 'initialization' part of a for loop?
It is executed only once at the beginning of the loop to set up the loop counter.
How do you track nested loop variables?
By creating a tracing table that includes columns for both outer and inner loop variables.
What is the significance of the 'update' part of a for loop?
It modifies the loop counter after each iteration, controlling the loop's progress.
Why is it important to pay attention to spaces and newlines in output?
Because they affect the final output and must be accurately tracked during code tracing.
What are the differences between for and while loops?
For loop: Used for known number of iterations, initialization/condition/update in one line. While loop: Used for unknown number of iterations, condition checked before each iteration, update manual.
What are the differences between single and nested loops?
Single loop: Iterates a block of code once for each value. Nested loop: An inner loop runs completely for each iteration of the outer loop.
What are the differences between print and println?
print: Prints output to the console without a newline. println: Prints output to the console with a newline.
What is code tracing?
Manually executing code line by line, tracking variable values.
What is a tracing table?
A table used to organize code tracing, with columns for iteration, variables, and output.
What is a for loop?
A control flow statement for iterating a specific number of times.
What is a while loop?
A control flow statement that executes a block of code as long as a condition is true.
What is an iteration?
A single pass through a loop's code block.
What is initialization (in a loop)?
The process of setting the initial value of a loop counter variable.
What is the condition (in a loop)?
A boolean expression that determines whether a loop continues to execute.
What is the update (in a loop)?
The modification of a loop counter variable after each iteration.
What is a nested loop?
A loop inside another loop.
What is output (in code tracing)?
The values printed to the console by the code.