Question



Which statement is false?

A.

All function calls in C pass arguments using call by value.

B.

Call by reference enables a called function to modify a variable in calling function.

C.

Call by value is always more efficient than call by reference.

D.

Programmers use pointers and indirection operation to simulate call by reference.

Correct option is C


Option (a): True. In C, all function calls pass arguments using call by value, meaning a copy of the value is passed to the function. Changes made to the parameter inside the function do not affect the original argument.
Option (b): True. Call by reference enables modifying a variable in the calling function by passing the address of the variable, allowing the function to directly manipulate the original value.
Option (c): False. Call by value is not always more efficient than call by reference. Passing large data structures or arrays by value creates a copy, consuming more memory and time. In contrast, call by reference passes only the address, which is more efficient in such cases.
Option (d): True. In C, pointers and indirection operators simulate call by reference, allowing direct modification of variables in the calling function.
Thus, the false statement is Option (c).
Information Booster:
1. Call by Value:
· A copy of the actual argument is passed to the function.
· Modifications inside the function do not affect the original variable.
· Safer as it protects the original data but less efficient for large data structures.
2. Call by Reference:
· The address of the variable is passed to the function.
· Enables modification of the original data.
· More efficient for large structures or frequent data manipulations but requires careful handling to avoid unintended changes.
3. Simulating Call by Reference in C:
· Use pointers to pass the address of variables.
· Example:
void modify(int *x) {
*x = 10;
}
4. Efficiency Consideration:
· Small data types (e.g., integers, floats) are faster with call by value.
· Large data types (e.g., arrays, structs) are more efficient with call by reference.
Additional Knowledge:
· Pointers in C:
· Enable dynamic memory allocation.
· Facilitate efficient function calls and memory management.
· Drawbacks of Call by Reference:
· Potential for unintentional changes to the original data.
· More complex to implement due to pointer usage.

Free Tests

Free
Must Attempt

Basics of Education: Pedagogy, Andragogy, and Hutagogy

languageIcon English
  • pdpQsnIcon10 Questions
  • pdpsheetsIcon20 Marks
  • timerIcon12 Mins
languageIcon English
Free
Must Attempt

UGC NET Paper 1 Mock Test 1

languageIcon English
  • pdpQsnIcon50 Questions
  • pdpsheetsIcon100 Marks
  • timerIcon60 Mins
languageIcon English
Free
Must Attempt

Basics of Education: Pedagogy, Andragogy, and Hutagogy

languageIcon English
  • pdpQsnIcon10 Questions
  • pdpsheetsIcon20 Marks
  • timerIcon12 Mins
languageIcon English
test-prime-package

Access ‘UGC NET Computer Science’ Mock Tests with

  • 60000+ Mocks and Previous Year Papers
  • Unlimited Re-Attempts
  • Personalised Report Card
  • 500% Refund on Final Selection
  • Largest Community
students-icon
353k+ students have already unlocked exclusive benefits with Test Prime!
Our Plans
Monthsup-arrow