When does a `while` loop test its condition?
A `while` loop tests its condition before executing the body, so it may execute zero times.
Study 04 Loops and Iteration with 12 free online flashcards. Review key terms, definitions, and concepts with this interactive flashcard deck.
When does a `while` loop test its condition?
A `while` loop tests its condition before executing the body, so it may execute zero times.
What guarantees that a `do-while` body runs once?
A `do-while` loop executes its body first, then tests its condition, so the body runs at least once.
What three parts does a C++ `for` header combine?
A `for` header contains initialization, a condition, and an update expression.
What is the usual scope of a `for` initialization variable?
A variable declared in a `for` loop’s initialization normally has scope only within that loop.
What does `break` do inside nested loops?
`break` immediately terminates the innermost enclosing loop and continues with the first statement afterward.
What happens after `continue` in a `for` loop?
In a `for` loop, `continue` skips the rest of the body, then runs the update expression before testing the condition again.
Why can `continue` cause a `while` loop to become infinite?
In a `while` loop, update the condition’s control variable before `continue`; otherwise, the condition may never change and the loop may not terminate.
What is an accumulator used for?
An accumulator stores a running result; initialize it before the loop and update it during every relevant iteration.
What is a sentinel in input processing?
A sentinel is a special input value that signals the end of input and is usually not processed as ordinary data.
What is the purpose of a validation loop?
A validation loop repeatedly requests input until the value satisfies the required condition.
How many times does a nested grid body execute?
For a rectangular grid with `r` rows and `c` columns, the inner loop body executes r×c times.
What causes a loop to become infinite?
A loop can fail to terminate when its condition-control state never changes toward making the condition false.
A 14-question medium-difficulty quiz on Boolean algebra, logic gates, truth tables, and combinational circuits.
A focused set of flashcards covering Python variables, data types, expressions, control flow, functions, input, output, and common programming practices.
Learn how Boolean expressions, logical operators, and conditional structures let programs make reliable decisions, including how to handle boundaries, branch order, and testing.
Learn how computer memory stores and addresses information, how RAM and ROM differ, and how caches and the memory hierarchy balance speed, capacity, and cost.
A progressive guide to tree structure, binary-tree traversals, binary search tree operations, deletion, balancing, and the way tree height determines time and space costs.
A practical guide to integrating problem definition, data representation, modular programming, algorithms, complexity analysis, testing, correctness, and ethical evaluation into a responsible computer science capstone.
Reviews how interrupts support event handling and multitasking, and how Linux system calls use the RISC-V `ecall` instruction and register conventions.
This quiz covers process management, context switching and scheduling, multitasking, traps and interrupts, and RISC-V privilege transitions.
A quiz on operating-system system calls, including privileged-operation requests, process creation and execution with fork, exec, and waitpid, and signal handling.