Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.
This Input, process, output in one short program worksheet is part of the IGCSE Computer Science 0478 — 8.1a Data Types and Variables journey. Print it as a booklet?
Shade in the A or B circle for each question.
Draw a line connecting each item on the left to its match on the right.
| Left column | Right column | |
|---|---|---|
| 1INPUT Width | AOUTPUT is placed before Area is calculated, so it would display a variable that has no value yet. | |
| 2Area ← Width * Height | BProcesses the data: it calculates a result from the input values and stores it in the variable Area. | |
| 3Show the result to the user as the last step of the program, after it has been calculated | CThe calculation comes before the INPUT lines, so Price and Quantity have no values yet when Total is worked out. | |
| 4Declare a variable with its data type before the program uses it to store a value | DReads a value typed by the user and stores it in the variable Width, so it must come before any calculation that uses Width. | |
| 5Total ← Price * Quantity INPUT Price INPUT Quantity OUTPUT Total | EOUTPUT "Total cost: ", TotalCost | |
| 6INPUT Length INPUT Width OUTPUT Area Area ← Length * Width | FDECLARE Price : REAL |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
INPUT, ←, OUTPUT — A simple program's order: DECLARE variables, INPUT values, calculate with an assignment (←), then OUTPUT the result. Each step must come before the one that uses it.DECLARE Price : REAL
INPUT Price
OUTPUT Price * 3DECLARE Width : INTEGER
INPUT Width
OUTPUT Width * WidthINPUT Side
Area ← Side * Side
OUTPUT AreaINPUT Quantity
Total ← Quantity * 2.5
OUTPUT TotalINPUT Price
Total ← Price * 3
OUTPUT Total