Skip to study material
← Question index

QUESTION 02 · Selection

Explain the types of control statements in C.

5 marks

Answer in brief

Control statements decide which statements execute, how often they execute and when control moves to another part of a program.

Sequential execution

Normally, C executes statements in their written order within a block. For example, reading two values, calculating their sum and printing it is a sequence. Control statements change this flow when a problem requires a choice or repeated work.

Selection statements

  1. if executes a block when a condition is true.
  2. if-else chooses between two alternatives. Nested if and an else-if ladder allow several decisions.
  3. switch selects a starting case using an integer or enumeration value.

Repetition statements

  1. while checks a condition before each iteration.
  2. for places initialisation, a condition and an update together.
  3. do-while checks the condition after the body, so the body runs at least once.

Jump statements

  1. break leaves the nearest loop or switch.
  2. continue skips the rest of the current loop iteration.
  3. goto transfers control to a label in the same function. return leaves the current function.

Example

A marks-processing program may use a loop to read several marks and an if-else statement to display Pass or Fail for each mark. The loop handles repetition, while the decision handles selection. Use braces to show which statements belong to each block. In a condition, zero means false and a non-zero value means true.

Related exam questions

Related questions in the selection category from the supplied papers. The marks below are the printed allocations, including any combined subquestion.

  • March/April 2023 · Q3(a) · 5 marks

    Discuss decision-making statements with an example.

    Paper P02 · page 1
  • June 2022 · Q2(b) · 8 marks

    Illustrate forms of if statements with syntax and examples.

    Paper P03 · page 1

View this category in the exam question bank →