Skip to content · ⁨ข้ามไปยังเนื้อหา⁩

Your first function · ⁨ฟังก์ชันแรกของคุณ⁩

English

Your first function

Up to now you printed things. A function is a small machine: you give it an input and it returns an answer. You write the inside; the checker tries it with several inputs.

return hands the answer back. Complete double so it returns n times two.

ไทย

ฟังก์ชันแรกของคุณ

จนถึงตอนนี้คุณได้พิมพ์สิ่งต่างๆ ออกมา ฟังก์ชัน (function) คือเครื่องจักรขนาดเล็ก: คุณป้อนอินพุตเข้าไป มันจะ return คำตอบออกมา คุณเขียนส่วนภายใน; ตัวตรวจสอบจะลองใช้กับอินพุตหลายชุด

return ส่งคำตอบกลับมา เติม double ให้เสร็จสมบูรณ์เพื่อให้มัน return n คูณสอง

Log in or create account · ⁨เข้าสู่ระบบหรือสร้างบัญชี⁩

IGCSE, A-Level & AP