Programming Concepts (CIE IGCSE Computer Science)

Topic Questions

1
Sme Calculator
4 marks

Four pseudocode descriptions and five pseudocode statements are shown.

Draw a line to link each pseudocode description to the most appropriate pseudocode statement.

Some pseudocode statements will not be used.q1-paper2-spec2023-cie-igcse-computerscience
[4]

Did this page help you?

2
Sme Calculator
1 mark

Tick () one box to show the named section of a program that performs a specific task.

A file box enclose space space space end enclose
B function box enclose space space space end enclose
C parameter box enclose space space space end enclose
D process box enclose space space space end enclose

[1]

Did this page help you?

3
Sme Calculator
1 mark

A function is declared using pseudocode.

      FUNCTION ConvertToCm(Inches: REAL) RETURNS REAL
        RETURN Inches * 2.4
      ENDFUNCTION

Tick () one box which accurately describes the use of the variable Inches

A answer box enclose space space space end enclose
B call box enclose space space space end enclose
C parameter box enclose space space space end enclose
D response box enclose space space space end enclose

[1]

Did this page help you?

4a
Sme Calculator
3 marks

The variables X, Y and Z are used to store data in a program:

  • X stores a string
  • Y stores a position in the string (e.g. 2)
  • Z stores the number of characters in the string.
a)
Write pseudocode statements to declare the variables X, Y and Z.
[3]
4b
Sme Calculator
6 marks
b)
The function Length(X) finds the length of a string X.

The function SubString(X,Y,Z) finds a substring of X starting at position Y and Z characters long. The first character in X is in position 1.

Write pseudocode statements to:
  • store the string "Programming is fun" in X
  • find the length of the string and output it
  •  extract the word fun from the string and output it.

[6]

Did this page help you?

5
Sme Calculator
6 marks

TASK 1 – Set up arrays
Set-up one dimensional arrays to store:

• Student names
• Student marks for Test 1, Test 2 and Test 3

o Test 1 is out of 20 marks
o Test 2 is out of 25 marks
o Test 3 is out of 35 marks

• Total score for each student

Input and store the names for 30 students. You may assume that the students’ names are unique.
Input and store the students’ marks for Test 1, Test 2 and Test 3. All the marks must be validated on entry and any invalid marks rejected.

TASK 2 – Calculate

Calculate the total score for each student and store in the array.
Calculate the average total score for the whole class.

Output each student’s name followed by their total score.
Output the average total score for the class.

TASK 3 – Select
Select the student with the highest total score and output their name and total score.

(i)
Explain how you select the student with the highest score (Task 3). You may include pseudocode or programming statements to help illustrate your explanation.

[5]

ii)
How does your program work when there is more than one student having the highest score? Explain using your method given in part (d)(i).

[1]

Did this page help you?

6a
Sme Calculator
3 marks
a)
Write an algorithm, using pseudocode or flowchart only, which:

           infinity  inputs three numbers
           infinity  outputs the largest of the three numbers

[3]

6b
Sme Calculator
4 marks
b)
Write an algorithm, using pseudocode or flowchart only, which:

infinity    inputs 1000 numbers
infinity    outputs how many of these numbers were whole numbers (integers)
       (You may use INT(x) in your answer, e.g. y = INT(3.8) gives the value y = 3)
[4]

Did this page help you?

7a
Sme Calculator
7 marks

Task 1 – Setting up the voting system to allow a tutor group to elect a representative. Write a program to:

  • allow the tutor to enter the name of the tutor group
  • allow the tutor to enter the number of students in the tutor group
  • allow the tutor to enter the number of candidates in the election; maximum of four candidates
    allow the tutor to enter the names of the candidates and store them in a suitable data structure
  • allow each student to input their vote or to abstain
  • count the votes for each candidate and student abstentions

When all students have voted, display the name of the tutor group, the votes for each candidate and the name of the candidate who has won the election. If there is a tie for first place, display all candidates with the equal highest number of votes.

a)
All variables, constants and other identifiers must have meaningful names.

i)
Identify one constant you could have used for Task 1, give the value that would be assigned to it and its use.

Constant .........................................................
Value ................................................................
Use ....................................................................
[3]
ii)
Identify one variable and one array you could have used for Task 1.
Explain the use of each one.

Variable ..........................................................
Use ...................................................................

Array ................................................................
Use ....................................................................
[4]
7b
Sme Calculator
4 marks
b)
Explain how you should change your program in Task 1 to allow a tutor to enter up to eight candidates for the election.
 [4]
7c
Sme Calculator
5 marks

Task 2 – Checking that students only vote once.
Each student is given a unique voter number by their teacher.
Extend
Task 1 to achieve the following:

  • Allow students to enter their unique voter number before casting their vote
  • Check whether the student has already voted
    • if so, supply a suitable message and do not allow them to vote
    • if not, store the unique voter number, but not their vote, in a suitable data structure, and add their vote to the relevant candidate count or abstention
c)
Write an algorithm using pseudocode, programming statements or a flowchart to show how your program completes these parts of Task 2:
  • Allows students to enter their unique voter number before casting their vote.
  • Checks whether the student has already voted:
    – if so, supplies a suitable message and does not allow them to vote.
    – if not, stores the unique voter number, but not their vote, in a suitable data structure.
It is not necessary to show parts completed in Task 1, including counting of votes for each candidate.

[5]

7d
Sme Calculator
4 marks

Task 3 – Showing statistics and dealing with a tie. Extend Task 2 to achieve the following:

  • Calculate the percentage of the votes that each candidate received from the number of votes cast, excluding abstentions
  • Display the name of each candidate, the number of votes and the percentage of votes they received from the number of votes cast, excluding abstentions
  • Display the total number of votes cast in the election and the number of abstentions
  • In the event of a tie, allow the election to be immediately run again, with only the tied candidates as candidates, and all the students from the tutor group voting again
d)
Explain how your program completes these parts of Task 3:
  • Calculate the percentage of the votes that each candidate received from the number of votes cast, excluding abstentions.
  • Display the name of each candidate, the number of votes and the percentage of votes they received from the number of votes cast, excluding abstentions.
  • Display the total number of votes cast in the election and the number of abstentions.
Any programming statements used in your answer must be fully explained.
[4]

Did this page help you?

8
Sme Calculator
6 marks

Name and describe the most appropriate programming data type for each of the examples of data given. Each data type must be different.

Data: 37
Data type name ............................................................................
Data type description ..................................................................


Data: Cambridge2021
Data type name .............................................................................
Data type description ...................................................................


Data: 47.86
Data type name .............................................................................
Data type description ...................................................................

[6]

Did this page help you?

9
Sme Calculator
3 marks

The pseudocode algorithm shown has been written by a teacher to enter marks for the students in her class and then to apply some simple processing.

Count ← 0
REPEAT
   INPUT Score[Count]
   IF Score[Count] >= 70
      THEN
         Grade[Count] ← "A"
      ELSE
         IF Score[Count] >= 60
            THEN
               Grade[Count] ← "B"
            ELSE
               IF Score[Count] >= 50
                  THEN
                     Grade[Count] ← "C"
                  ELSE
                     IF Score[Count] >= 40
                        THEN
                           Grade[Count] ← "D"
                        ELSE
                           IF Score[Count] >= 30
                              THEN
                                 Grade[Count] ← "E"
                              ELSE
                                 Grade[Count] ← "F"
                              ENDIF
                           ENDIF
                        ENDIF
                     ENDIF
                  ENDIF
                  Count ← Count + 1
               UNTIL Count = 30

Describe how you could change the algorithm to allow teachers to use it with any size of class.

[3]

Did this page help you?