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 วินาที

อยากฝึกโจทย์แบบนี้เพิ่มไหม เริ่มฝึกหัวข้อนี้ได้เลย ตรวจให้ทันทีทุกข้อ

เริ่มฝึกเลย