Why is code written inside functions easier to test?

  1. Functions never contain errors
  2. Each function can be called with test inputs and its return value checked
  3. Code outside functions cannot run
  4. Functions are compiled separately
Answer

B) Each function can be called with test inputs and its return value checked

Unit tests call a function and compare the result with the expected value. SLO CS-11-C-07 · Understanding

Computer Science MCQ · More Unit 3: Programming Fundamentals MCQs · Practise