AMP

Chapter 11: Functions — Online MCQ Test

COMPUTER SCIENCE · CLASS 11th · Tamil Nadu State Board
Practice Chapter 11: Functions with a free chapter-wise online MCQ test. This chapter covers: Focusing on modular programming this chapter covers function declarations parameters passing mechanisms call-by-value call-by-reference and scope rules. Students explore inline fun.... AI-generated questions from basic to board-exam level, with instant results and explanations.

Start Exam on Full Site →

Chapter 11: Functions — Important Questions & Answers

What is the primary advantage of using functions in C++?
  • A. To increase memory usage
  • B. To promote code reusability and modularity
  • C. To make the program execute faster automatically
  • D. To eliminate the need for variables
Answer: B. To promote code reusability and modularity
Functions allow breaking down large programs into smaller, manageable, and reusable blocks of code.
Which of the following is a parameter type where the actual value is copied to the formal parameter?
  • A. Call-by-reference
  • B. Call-by-address
  • C. Call-by-value
  • D. Call-by-pointer
Answer: C. Call-by-value
In call-by-value, a copy of the actual argument's value is passed to the function, so changes to the formal parameter do not affect the original value.
In C++, what character is used to denote a reference parameter in a function definition?
  • A. *
  • B. &
  • C. %
  • D. #
Answer: B. &
The address-of operator '&' is used in the function signature to indicate that the parameter is passed by reference.
Analyze the effect: If a function uses 'call-by-reference', what is the impact on the original variable passed from the main function?
  • A. The original variable remains unchanged
  • B. The original variable is copied to a new memory location
  • C. Changes made to the formal parameter affect the original variable
  • D. The program results in a segmentation fault
Answer: C. Changes made to the formal parameter affect the original variable
Call-by-reference passes the memory address, so any modification to the formal parameter directly updates the original argument.
In a scope conflict, which variable takes precedence?
  • A. Global variable
  • B. Local variable
  • C. Static variable
  • D. None, the compiler throws an error
Answer: B. Local variable
A local variable with the same name as a global variable will 'shadow' the global variable, taking precedence within the local scope.