Answer
Flashcards · 9618 · AS Topic 11
Programming (AS Level) flashcards
15 cards on AS Topic 11, subtopics 11.1 to 11.3. Pick a subtopic or study them all.
Study mode needs JavaScript. Every card is listed below, so you can still cover the answers and test yourself.
Choose your cards
Session complete
Worth another look:
All 15 cards
For a quick read-through or printing. Cover the right-hand side to test yourself.
11.1 Programming Basics
- What is the assignment operator in 9618 pseudocode?
- ← , for example Count ← Count + 1. The = sign is used for comparison and in CONSTANT declarations, not for assignment.
- How do you take input and give output in 9618 pseudocode?
- INPUT Name OUTPUT "Hello ", Name OUTPUT can print several items separated by commas.
- Which string functions does the 9618 pseudocode guide give?
- Examples: LENGTH(s) gives the number of characters; LEFT(s, x) and RIGHT(s, x) give x characters from either end; MID(s, x, y) gives y characters starting at position x. & joins (concatenates) strings.
- What do INT and RAND do in 9618 pseudocode?
- INT(x) returns the integer part of x (e.g. INT(27.9) is 27). RAND(x) returns a random real number from 0 up to but not including x.
- What are integer division and modulo? Give 17 and 5 as an example.
- Integer division gives the whole-number quotient: 17 divided by 5 gives 3. Modulo gives the remainder: 17 modulo 5 gives 2.
11.2 Constructs
- What is the structure of an IF statement in 9618 pseudocode?
- IF condition THEN statements ELSE statements ENDIF
- What is the structure of a CASE statement in 9618 pseudocode?
- CASE OF identifier value1 : statement value2 : statement OTHERWISE statement ENDCASE
- What is the structure of a count-controlled loop in 9618 pseudocode?
- FOR Count ← 1 TO 10 statements NEXT Count STEP can set the increment, e.g. FOR i ← 10 TO 0 STEP -2.
- What is the difference between a pre-condition and a post-condition loop?
- Pre-condition (WHILE condition … ENDWHILE): the condition is tested first, so the body may run zero times. Post-condition (REPEAT … UNTIL condition): the body always runs at least once.
- When does a WHILE loop stop and when does a REPEAT loop stop?
- WHILE repeats while its condition is TRUE and stops when it becomes FALSE. REPEAT … UNTIL repeats until its condition becomes TRUE.
11.3 Structured Programming
- What is the difference between a procedure and a function?
- A function returns a single value and is used in an expression. A procedure performs a task and is run with CALL; it returns no value directly.
- How do you write a function in 9618 pseudocode?
- FUNCTION Square(Num : INTEGER) RETURNS INTEGER RETURN Num * Num ENDFUNCTION
- How do you write and call a procedure in 9618 pseudocode?
- PROCEDURE Greet(Name : STRING) OUTPUT "Hello ", Name ENDPROCEDURE CALL Greet("Ali")
- What is the difference between passing a parameter BYVAL and BYREF?
- BYVAL: a copy of the value is passed, so the original variable is not changed. BYREF: the address is passed, so changes made in the subroutine change the original. If neither is stated, BYVAL is assumed.
- What is the difference between a parameter and an argument?
- A parameter is the variable named in the subroutine header. An argument is the actual value passed to it when the subroutine is called.