Skip to content
MathsGenie logo
Open app

Course home

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

Algorithms

EasyMedium
123456789101112131415161718192021222324252627
Question 22

Consider the following pseudocode algorithm:

1  SET base TO 0
2  SET exponent TO 0
3  SET result TO 1
4  SET i TO 0
5
6  SEND "Enter base number: " TO DISPLAY
7  RECEIVE base FROM (INTEGER) KEYBOARD
8  SEND "Enter positive exponent: " TO DISPLAY
9  RECEIVE exponent FROM (INTEGER) KEYBOARD
10
11 IF (exponent < 0) THEN
12     SEND "Error: Exponent must be non-negative" TO DISPLAY
13 ELSE
14     FOR i FROM 1 TO exponent DO
15         SET result TO result * base
16     END FOR
17     SEND "The result is " & result TO DISPLAY
18 ENDIF

State the purpose of this algorithm.

[1]

Algorithms Questions

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