Pearson Edexcel IGCSE · Computer Science

程式結構:練習題

2 條多項選擇題即時批改,另有 4 條文字題附完整解題步驟,全部圍繞「程式結構」。

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 秒完成。

想多做幾條同類題目?立即開始練習呢個課題,即做即批改。

立即練習