When can a while loop execute zero times?
A while loop tests its condition before each iteration, so its body can execute zero times.
Study 4 Repetition and Looping with 12 free online flashcards. Review key terms, definitions, and concepts with this interactive flashcard deck.
When can a while loop execute zero times?
A while loop tests its condition before each iteration, so its body can execute zero times.
What guarantees that a do-while loop runs once?
A do-while loop executes its body before testing the condition, so it always runs at least once.
What punctuation follows a do-while condition?
The semicolon terminates the do-while statement: do { /* body */ } while (condition);
What is the execution order of a for loop?
A for loop initializes once, tests before each iteration, runs the body, updates, and then tests again.
When is a for loop a natural choice?
Use a for loop when a counter or another regular progression naturally describes the repetition.
What does break do inside a loop?
break immediately exits the nearest enclosing loop and continues with the first statement after that loop.
What does continue do in a for loop?
continue skips the rest of the current iteration and begins the next one. In a for loop, the update runs first.
How many times can a nested-loop body execute?
A nested loop's body executes once for each outer iteration combined with each inner iteration: r times c times, or r×c.
What is the structure of an accumulation loop?
Initialize an accumulator before the loop, then update it once per visited value, such as total += value.
How does a loop count matching values?
A counting loop increments a counter whenever an item satisfies a condition, such as value > 0.
What is a sentinel-controlled loop?
A sentinel-controlled loop stops when a special value appears; in the example, -1 ends input and is not added to the total.
Which index condition avoids an array off-by-one error?
For a zero-based array with size elements, use i < size because valid indices are 0 through size - 1.
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.