Pearson Edexcel GCSE (9-1) · Computer Science (1CP2)

Subprograms:練習問題

その場で採点される選択問題 5 問と、解説つきの記述問題 5 問。すべて「Subprograms」からの出題です。

10 問28 無料・登録不要
問 1
1

A programmer wants to break down a complex problem into smaller, manageable parts. What is a primary benefit of using subprograms for this purpose?

問 2
1

A function is defined as follows:
function calculate(a, b)
    return a * b + 2
endfunction

What is the output of print(calculate(3, 4))?

問 3
1

A subprogram is designed to update a user's score in a database but does not need to send any data back to the part of the program that called it. Which type of subprogram is this?

問 4
1

Which of the following describes the difference between a global variable and a local variable used within a subprogram?

問 5
1

Which of the following is a potential risk of using global variables instead of passing parameters to subprograms?

問 6
3

Explain why a programmer would use a function rather than a procedure when calculating the square root of a number.

まず自分で答えを書いてから、解説と照らし合わせましょう。

問 7
5

A variable total is declared inside a subprogram. Explain the effect on the program if you attempt to access total from the main program block.

まず自分で答えを書いてから、解説と照らし合わせましょう。

問 8
6

Describe two characteristics of a function that distinguish it from a procedure within the Pearson Edexcel PLS.

まず自分で答えを書いてから、解説と照らし合わせましょう。

問 9
3

A program uses a subprogram to calculate the total price of items including tax. The subprogram takes the price as an input and returns the final value.

(a) Explain one benefit of using subprograms in this scenario.
(b) Define the difference between a parameter and an argument in the context of this subprogram.

まず自分で答えを書いてから、解説と照らし合わせましょう。

問 10
6

Consider the following subprogram snippet:
FUNCTION calculate(a, b)
  global total
  total = a + b
  RETURN total * 2
ENDFUNCTION


(a) Distinguish between the local variables and global variables in this snippet.
(b) Explain one potential risk of using the global keyword inside a subprogram.
(c) Rewrite the subprogram so it does not use a global variable but still allows the calling program to use the sum.

まず自分で答えを書いてから、解説と照らし合わせましょう。

※ thinkaのコンテンツはAIにより生成されているため、内容が正確でない場合があります。補助教材としてご使用いただき、公式の教材と合わせてご確認ください。

模範解答は見ました。次はあなたの答案を採点します。

このページは良い答案の形を示せますが、あなたの答案に何が足りないかは教えられません。thinka は実際の採点基準に沿って記述答案を約 15 秒で採点します。

同じような問題をもっと解きたい?このトピックの新しい問題を、解きながら採点。

練習を始める