Skip to content
MathsGenie logo
Open app

Course home

  1. IGCSE
  2. Computer Science Edexcel
  3. Question bank

Constructs

EasyMedium
1234567891011121314
Question 4

The pseudocode below shows a function designed to calculate the sum of all even numbers up to a given limit, and call it within a main program.

1 FUNCTION sumEven(limit)
2 BEGIN FUNCTION
3     total = 0
4     IF limit < 2 THEN
5         total = 0
6     ELSE
7         FOR i FROM 2 TO limit STEP 2 DO
8             total = total + i
9         END FOR
10    END IF
11    RETURN total
12 END FUNCTION
13
14 OUTPUT "Enter limit: "
15 INPUT limitFromUser
16 ans = sumEven(limitFromUser)
17 OUTPUT "Total sum is: " + ans

Identify the line number where iteration starts.

[1]

Constructs Questions

  1. IGCSE
  2. /Computer Science
  3. /Constructs