topic badge
CanadaON
Grade 8

11.06 Algorithms in code

Worksheet
Algorithms in code
1

Determine the value that is printed at the end of the following pseudocodes:

a
\text{START}\\ \text{SET } a=73\\ \text{SET } b=44\\ \text{SET } c=a+b\\ \text{PRINT } c \\ \text{END}
b
\text{START}\\ \text{SET } a=26\\ \text{SET } b=11\\ \text{SET } c=a*b\\ \text{PRINT } c \\ \text{END}
c
\text{START}\\ \text{SET } a=2\\ \text{SET } b=a * a * a\\ \text{PRINT } b \\ \text{END}
d
\text{START}\\ \text{SET } a=1\\ \text{SET } b=3\\ \text{SET } c=a \land b\\ \text{PRINT } c \\ \text{END}
e
\text{START}\\ \text{SET } a=11\\ \text{SET } b=18 \\ \text{IF } a>=b\\ \qquad \text{THEN PRINT } a\\ \text{ELSE PRINT } b\\ \text{END IF} \\ \text{END}
f
\text{START}\\ \text{SET } a=7\\ \text{SET } b=5 \\ \text{SET } m=(a+b)\,/\,2 \\ \text{PRINT } m\\ \text{END}
g
\text{START}\\ \text{SET } a=4\\ \text{SET } b=3 \\ \text{SET } c=9 \\\text{SET } d=a+b*c\\ \text{PRINT } d\\ \text{END}
h
\text{START}\\ \text{SET } a=78\\ a=a+73 \\ \text{PRINT } a\\ \text{END}
2

What statement is printed at the end of the following pseudocode?

\text{START}\\ \text{SET } a=8\\ \text{IF } a\,/\,2 \text{ IS integer}\\ \qquad \text{THEN PRINT } "a \text{ is even}"\\ \text{ELSE PRINT} "a \text{ is odd}"\\ \text{END IF }\\ \text{END}

3

Consider the following pseudocode with steps in the wrong order:

StepCode
A\text{ SET } a=2
B\text{ END}
C\text{ SET b=3}
D\text{ PRINT } a+b
E\text{ START}
a

Arrange the steps of the algorithm in the correct order.

b

What is printed at the end of the code?

4

Consider the following pseudocode:

a

What does the code calculate?

A

Volume

B

Units

C

Area

D

Perimeter

b

What is the output of this code?

\text{START}\\ \text{SET } W=3\\ \text{SET } L=6\\ \text{SET } A=W*L\\ \text{PRINT } A\,"\text{m}^2"\\\text{END}

5

Consider the following pseudocode:

a

What does the code calculate?

A

Volume

B

Units

C

Area

D

Perimeter

b

What is the output of this code?

\text{START}\\ \text{SET } W=7\\ \text{SET } L=9\\ \text{SET } P=2*W+2*L\\ \text{PRINT } P\,"\text{m}"\\\text{END}

Sign up to access Worksheet
Get full access to our content with a Mathspace account

Outcomes

8.C3.1

Solve problems and create computational representations of mathematical situations by writing and executing code, including code that involves the analysis of data in order to inform and communicate decisions.

8.C3.2

Read and alter existing code involving the analysis of data in order to inform and communicate decisions, and describe how changes to the code affect the outcomes and the efficiency of the code.

What is Mathspace

About Mathspace