AQA GCSE COMPUTER SCIENCE Paper 1 Computational thinking and programming skills – C# 2023
Figure 1 shows an algorithm, represented using pseudo-code, which assigns a different value to four variables. Figure 1 country 'United States of America' state 'California' city 'San Francisco' landmark 'Alcatraz Island' . 1 Define the term algorithm. The variable x is assigned a value using the statement: x LEN(state) Using Figure 1, what is the value of x? Shade one lozenge. What is the result of concatenating the contents of the variables city and landmark in Figure 1? Shade one lozenge. The subroutine SUBSTRING extracts characters from a given string. For example, SUBSTRING(3, 5, 'Computing') would return put The variable y is assigned a value using the statement: y SUBSTRING(4, 7, landmark) Using Figure 1, what is the value of y? Shade one lozenge. The subroutine POSITION finds the first position of a character in a string. For example, POSITION('Computing', 'p') would return 3 The variable z is assigned a value using the statement: z POSITION(landmark, 't') Using Figure 1, what value is assigned to z? Shade one lozenge. Figure 2 shows an algorithm that uses integer division which has been represented using pseudo-code. • Line numbers are included but are not part of the algorithm. Figure 2 1 again True 2 WHILE again = True 3 a USERINPUT 4 IF a > 0 THEN 5 counter 0 6 WHILE a > 0 7 a a DIV 3 8 counter counter + 1 9 ENDWHILE 10 ELSE 11 again False 12 ENDIF 13 OUTPUT a 14 ENDWHILE Integer division is the number of times one integer divides into another, with the remainder ignored. For example: • 14 DIV 5 evaluates to 2 • 25 DIV 3 evaluates to 8 11 Do not write outside the box Turn over ► IB/G/Jun23/8525/1A . 1 0 2 Where is iteration first used in the algorithm in Figure 2? Shade one lozenge. Figure 3 shows a program written in C# that calculates the area of a rectangle or the volume of a box from the user inputs. Figure 3 public static int calculate(int width, int length, int height) { if (height == -1) { return width * length; } else { return width * length * height; } } public static void Main() { int numOne, numTwo, numThree, answer; Console.Write("Enter width: "); numOne = Convert.ToInt32(Console.ReadLine()); Console.Write("Enter length: "); numTwo = Convert.ToInt32(Console.ReadLine()); Console.Write("Enter height, -1 to ignore: "); numThree = Convert.ToInt32(Console.ReadLine()); answer = calculate(numOne, numTwo, numThree); if (numThree == -1) { Console.WriteLine($"Area {answer}"); } else { Console.WriteLine($"Volume {answer}");
Written for
- Institution
- Computer Science
- Course
- Computer Science
Document information
- Uploaded on
- January 12, 2024
- Number of pages
- 98
- Written in
- 2023/2024
- Type
- Exam (elaborations)
- Contains
- Only questions
Subjects
-
aqa gcse computer science paper 1 computational th
-
figure 1 shows an algorithm represented using ps
-
the variable x is assigned a value using the state
-
what is the result of concatenating the contents