Past-paper question · 2015 October-November · Paper 21 · Q8(a)

Question 8(a) 2015 · October-November · Paper 21 · 1 mark

Original past-paper question for 8(A)
Original past-paper question for 8(A)
Reveal official mark-scheme answer Official mark-scheme answer for 8(A)

Official answer for Question 8

Part (a)

Part (a)

r

[1]

Mark scheme 9608_w15_ms_21.pdf →

Show text version of question

Question 8

Part (a)

Question 8

In this question you will need to use the given pseudocode built-in function:

ONECHAR(ThisString : STRING, Position : INTEGER) RETURNS CHAR returns the single character at position Position (counting from the start of the string with value 1) from the string ThisString. For example: ONECHAR("Barcelona", 3) returns 'r'.

Part (a)

Give the value assigned to variable y by the following statement:

y ← ONECHAR("San Francisco", 6) y .............................................

[1]
A
program reads a string entered by the user. The string represents the addition or subtraction

of two fractions. Each part of the fraction within the string is always a single digit only and the top digit is always less than the bottom digit.

Example strings are: "3/8+3/5" and "5/8-1/4"

The program steps are:

  • the user enters the string
  • the program isolates each digit and the operator
  • the program computes the answer as either:
  • a fraction a whole number followed by a fraction a whole number

  • the program displays the answer to the user

Op

é

N4Char N3Char N2Char N1Char

The identifier table shows the variables to be used to store the characters in the string as shown in the diagram.

Identifier Data type Description

FractionString String input by user. STRING For example: "5/8-1/4" N1Char CHAR See diagram N2Char CHAR See diagram N3Char CHAR See diagram N4Char CHAR See diagram Op CHAR See diagram

Question 17

Topic relevance

Why this question appears here

82% assigned-topic match · Data types and structures › Data types and records

Topic-match percentages estimate how closely each question fits the selected syllabus topic. They are a guide for choosing stricter or broader practice.

Permanent source page: Educate A Change · From 9608_w15_qp_21.pdf

Keep practising this topic