Imperative Programming Structure and Flow Control MCQs: 12 Solved Questions
Test whether you can trace changing state, choose the right loop, read a flowchart, and follow event-driven or exceptional control paths through 12 solved MCQs.
KnowledgeGate Team
Exam prep & CS education

Loop keywords are easy to recall, even under time pressure, but exam questions rarely stop at definitions. They test whether you can trace a changing variable, distinguish program structure from control flow, and decide which statement executes next when an event or exception interrupts the usual sequence. The real challenge is keeping the current program state separate from the next condition being tested. Treat program construction, loop semantics, flowcharts, event handlers, and exceptions as variations of one question: what changes, and what executes next?
Imperative programming: state changes and next-step reasoning
Imperative programming uses statements that change program state. Assignments update values, while selection, iteration, calls, events, and exceptions redirect execution.
Four distinctions matter: program construction and structure, loop semantics, manual flow tracing, and non-linear control through events or exceptions. The wider Coding & DSA route gives you more practice with state changes and control decisions.
Attempt each item before its explanation. Whenever a variable changes, trace its value before and after the statement. That habit prevents most flow-control mistakes.
Program construction and structured design MCQs
Question 1: complete program execution sequence
Navodaya Vidyalaya Samiti, Computer Science, 2022
Which of the following options states the complete and correct sequence of steps to execute a program on a personal computer?
A. code → compile → link → load → execute
B. design → code → compile → link → load → execute
C. code → compile → load → execute
D. design → code → compile → load → execute
Answer: B. First design the logic, express it as source code, compile the source into object code, link the required object and library code, load the executable into memory, and then execute it. Option A omits design, option C omits design and linking, and option D omits linking. Source.
Question 2: structure chart versus program flowchart
RPSC Programmer - P2, Computer Science, 2024
__________, a program development tool, shows how the program has been partitioned into smaller more manageable modules, the hierarchy and organization of those modules and the communication interfaces between modules.
A. Structure Chart
B. Fourth Generation Language Tools (4GL Tools)
C. Object-Oriented Programming and Design Tools
D. Program Flow Chart
Answer: A. A structure chart shows which modules exist, how they are organised, and what information passes between them. A program flowchart shows which operation or decision runs next, so option D represents control flow rather than modular hierarchy. Source.
Question 3: the classic structured-programming language
BPSC PGT Tier-1, Computer Science, 2023
Which language is better for writing structured code?
A. PASCAL
B. FORTRAN
C. BASIC
D. More than one of the above
E. None of the above
Answer: A. In the question's classic language-design framing, Pascal was built around block structure, procedures, functions, and disciplined control constructs. The contrast is with historically less structured styles associated with early FORTRAN and BASIC. Object Oriented Technology Explained helps separate two ideas: structured control organises execution, while object orientation organises data and behaviour. Source.
Loop semantics and loop selection MCQs
Question 4: do-while entry condition
Beltron Programmer Shift-1, Computer Science, 2025
What is a unique characteristic of a do-while loop in programming?
A. It behaves exactly like a while loop.
B. It executes the loop body at least once before evaluating the condition.
C. The loop may skip executing the body entirely.
D. It checks the condition before executing the loop body.
Answer: B. A do-while loop follows body → test condition, while a while loop follows test condition → body. With int x = 5; do { x++; } while (x < 5);, the body runs once and changes x from 5 to 6, then the first test is false. Source.
Question 5: three parts of a for-loop header
Beltron Programmer Shift-2, Computer Science, 2025
Which of the following statements best describes the functionality of a for loop in programming?
A. It initialises, checks condition, and updates control variable in a single line.
B. It continuously executes without checking any condition.
C. It allows conditional execution only after running the loop body once.
D. It can only be used when the number of iterations is unknown.
Answer: A. In for (int i = 1; i <= 3; i++), initialisation sets i = 1, each pre-body test checks i <= 3, and each update increments i. The successful tests occur at i = 1, 2, and 3, so the body runs three times; the update then makes i = 4, and 4 <= 3 is false. Source.
Question 6: loop forms supported by PHP
BPSC NB, Computer Science, 2024
Which of the looping statements is/are supported by PHP? i) for loop ii) while loop iii) do-while loop iv) foreach loop
A. (i) and (ii)
B. (i), (ii) and (iii)
C. (i), (ii), (iii) and (iv)
D. More than one of the above
E. None of the above
Answer: C. PHP supports all four forms: for for counter-controlled repetition, while for pre-test repetition, do-while for post-test repetition, and foreach for collection traversal. Build loop traces with the C Language course; for adjacent C foundations, use C Programming Data Type MCQs. Source.
Flowchart tracing MCQ with a complete state table
Question 7: follow the decision, update, and back edge
Eklavya Model Residential Schools, Computer Science, 2023
Observe the following flowchart and find the output.

A. 180
B. 120
C. 100
D. 160
Answer: A. Trace the values only after following the YES branch:
Decision-time A | S before | S after addition | A after |
|---|---|---|---|
100 | 0 | 100 | 60 |
60 | 100 | 160 | 20 |
20 | 160 | 180 | -20 |
The next test, -20 >= 20, is false, so the NO branch outputs S = 180. Do not stop before processing A = 20, because equality makes 20 >= 20 true. Source.
Event-driven flow, event loops, and handlers MCQs
Question 8: what controls an event-driven program
DSSSB, Computer Science, 2022
An event-driven program is a program in which the flow of control of the program depends upon the ______.
A. occurrence of external events
B. control statements
C. sequence of statements
D. order of calling of functions
Answer: A. The next handler is selected by an event such as a click, key press, incoming message, or timer firing. The program still contains statements and function calls, but those elements do not decide which event-specific path becomes active. Source.
Question 9: recognise a real event
DSSSB, Computer Science, 2022
Which of the following statements is INCORRECT about event in an event-driven programming?
A. It is piece of data sent by producers.
B. It is piece of data that may be consumed by consumers.
C. An event does not occur when a key is pressed.
D. An event occurs when the left mouse button is clicked.
Answer: C. A key press is a standard input event, just like a mouse click. Producers emit event data, and consumers or registered handlers process it, which makes A, B, and D consistent with the event-driven model. Source.
Question 10: what an event loop does not do
DSSSB, Computer Science, 2022
Which of the following statements is INCORRECT about event-loop in an event-driven programming?
A. It performs two functions in a continuous loop.
B. Its event-detection function detects the happening of an event.
C. Its event-handler function executes the corresponding function associated with that event.
D. It is a looping statement that is used to generate the same events repeatedly.
Answer: D. Follow this mini-sequence: queue empty → click event arrives → loop detects click → click handler runs → loop waits again. The event loop detects and dispatches events from their sources; it does not manufacture the same event repeatedly. Source.
Question 11: callback and asynchronous dispatch
DSSSB, Computer Science, 2022
Which of the following statements is/are true about event-handler in an event-driven programming? (i) It is a call back routine. (ii) It operates asynchronously.
A. Only (i)
B. Only (ii)
C. Both (i) and (ii)
D. Neither (i) nor (ii)
Answer: C. In the question's intended model, an event handler is a callback registered for a particular event, and event arrival triggers its invocation outside the surrounding sequential statement order. Asynchronous dispatch does not mean that every handler runs on a separate thread; dispatch and parallel execution are different ideas. Source.
Exception handling as an alternate control path MCQ
Question 12: the main advantage of exception handling
Bihar STET, Computer Science, 2025
What is the main advantage of using exception handling in programming?
A. It prevents code from running
B. It improves code readability
C. It handles unexpected errors and allows graceful program termination
D. It eliminates the need for classes and objects
Answer: C. Consider the path parse input → conversion throws an exception → matching handler records the error → program returns a controlled message or terminates cleanly. Readability can improve as a side effect, but the central purpose is to separate normal execution from recoverable or terminating error flow. The Java course is a practical next step for structured exception handling. Source.
Imperative programming question patterns and the next practice step
The recurring exam moves are to order stages, distinguish related representations, predict loop entry and count, and follow alternate event or exception paths.
For revision, redraw Question 7's four-column trace, write pre-test and post-test loops with the same initial value, then narrate Question 10's event-loop sequence. Together, they practise state change, repetition, and non-linear dispatch.
Use C Language for sequential control and manual traces, or Java for exception-driven control. In either case, write the current state after every assignment before choosing the next branch.
Keep learning

Classes and Objects MCQs: 12 Solved OOP Questions with Explanations
Solve 12 classes and objects MCQs, check each explanation, and use a worked Java trace to separate instance state, constructors, overloading and nested classes.

Programming Language Syntax MCQs: 12 Solved Questions on Grammar, Tokens and Semantics
Solve 12 MCQs on syntax, tokens, pseudocode, C grammar and runtime behaviour. Each explanation identifies the rule and applies it.

Static vs Dynamic Binding MCQs: 11 Solved Questions on Scope, Aliasing and Dispatch
Solve 11 binding questions from GATE and UGC NET papers by tracing lexical scope, runtime call chains, declared types and shared storage cells. Each answer shows why the tempting shortcuts fail.

TypeScript vs C# Typing: Structural Compatibility, Nominal Identity, Generics and Runtime Checks
Follow one User/Admin example through TypeScript and C# to predict assignments, generic conversions, branded IDs, and JSON behaviour at runtime.