Revise Computingrevisecomputing.co.uk
Free student revisionSee questionsFor schoolsSchool enquiry
Free revisionSee questionsFor schoolsSchool enquiry
Knowledge/A Level/H446/02 Algorithms and programming/Thinking Logically/Determine the logical conditions that affect…

Determine the logical conditions that affect the outcome of a decision

Determine the logical conditions that affect the outcome of a decision.

2.1.4 Thinking Logically

Thinking Logically — Note 2 of 3

Candidates need to understand what these decisions are and the logical conditions that determine their outcome.

What you need to know

Each decision depends on a logical condition that evaluates to true or false. You need to write these conditions precisely, using comparison and Boolean operators.

What to know

  • Conditions use comparison operators (==, !=, <, <=, >, >=) and Boolean operators (AND, OR, NOT).
  • Check boundary values carefully: < and <= give different results at the boundary.
  • Complex conditions can be combined, with brackets to make the order clear.

Exam technique

  • Mistake:Writing if x > 5 AND < 10. The variable must be repeated: if x > 5 AND x < 10.
  • Mistake:Using OR when AND is needed. if mark < 0 OR mark > 100 checks for INVALID input; if mark >= 0 AND mark <= 100 checks for VALID input.
  • Tip:Test your condition with a value just inside, exactly on, and just outside each boundary.

Code examples

Logical conditions in OCR pseudocode
text
if age >= 13 AND age <= 19 then
    category = "Teen"
elseif age < 13 then
    category = "Child"
else
    category = "Adult"
endif
← Previous noteIdentify the points in a solution where a decision has to be taken2.1.4 Thinking LogicallyNext note →Determine how decisions affect flow through a program2.1.4 Thinking Logically

Back to Thinking Logically

Thinking Logically

Note 2 of 3

  1. 1Identify the points in a solution where a decision has to be taken
  2. 2Determine the logical conditions that affect the outcome of a decision
  3. 3Determine how decisions affect flow through a program
Topic overview