Pearson Edexcel IGCSE · Computer Science

Constructs:練習問題

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

6 問20 無料・登録不要
問 1
1

Study the following pseudocode which involves variable scope:

\( \text{SET globalVar TO 10} \)
\( \text{FUNCTION calculate(n)} \)
  \( \text{SET localVar TO n * 2} \)
  \( \text{SET globalVar TO globalVar + 5} \)
  \( \text{RETURN localVar} \)
\( \text{ENDFUNCTION} \)

If the main program calls \( \text{calculate(4)} \) once, what will be the final value of globalVar and the returned result?

問 2
1

Consider the following pseudocode fragment:

\( \text{SET count TO 0} \)
\( \text{FOR r FROM 0 TO 2} \)
  \( \text{FOR c FROM 0 TO 1} \)
    \( \text{IF vals[r][c] > 10 THEN} \)
      \( \text{SET count TO count + 1} \)
    \( \text{END IF} \)
  \( \text{END FOR} \)
\( \text{END FOR} \)

The 2D array \( \text{vals} \) contains the following data:
Row 0: 12, 5
Row 1: 8, 15
Row 2: 20, 7

What will be the final value of the variable \( \text{count} \) after execution?

問 3
3

Explain the primary difference between a count-controlled iteration and a condition-controlled iteration.

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

問 4
5

An algorithm uses a nested loop to calculate the sum of values in a 2D array. If the inner loop is defined as \( \text{FOR j FROM 0 TO 5} \) but the array rows only contain 4 elements (indices 0 to 3), identify the type of error that occurs and explain its impact on the program execution.

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

問 5
4

Selection and iteration are fundamental programming constructs.
(a) Describe the difference between a count-controlled loop (FOR loop) and a condition-controlled loop (WHILE loop).
(b) Provide one specific programming scenario where a WHILE loop would be a more appropriate choice than a FOR loop.

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

問 6
6

A programmer is writing a subprogram to calculate the discount on a customer order.
(a) Explain the difference between passing by value and passing by reference when providing arguments to a subprogram.
(b) Discuss the benefits of using local variables within this subprogram instead of using global variables to track calculation steps, referring to data security and memory management.

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

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

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

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

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

練習を始める