Question

Explain the concept of call by reference, with suitable code in C for each. Give advantage and disadvantage of call by reference

30 Nov 2023
Answer :
Word Count : 799

In programming, *Call by Reference* is a method of passing arguments to a function. Instead of passing a copy of the variable (as in call by value), the address (reference) of the variable is passed. This allows the function to modify the actual value of the variable in the caller's scope.

### Concept of Call by Reference

When a function is called using *call by reference*, the function receives the reference (memory address) of the arguments, which means any changes made to the parameter within the function will directly affect the actual argument in the calling function. This is different from *call by value*, where the function only works with a copy of the argument, and modifications within the function do not affect the original variable.

In C, call by reference is implemented using pointers. A pointer is a variable that stores the address of another variable, allowing direct manipulation of the variable's value.

### Call by Reference in C

In C, to implement call by reference, we pass the address of the variable to the function using pointers. Here is an example:

```c
#include <stdio.h>

void add(int *a, int *b) {
    *a = *a +

___ _________ _____ ________ ________ ____.
_____ _________ ________ __________ _________ _________ _______ ______ _______ _______ ___ _____.
_________ ______ ________ ________ _________ ___.
______ ____ ___ __________ _________ ________ ____ _____ _______ ______.
_________ ___ _____ ____ _________ ______ _________ ____ ____ _____.
_______ ________ __________ _______ _____ _______ _____ _____ ____ _______ _____.
_____ _______ ____ _____ ____ _____ ____ ___ __________.
_________ __________ _____ ________ _________ __________ ____ _______ _______.
_______ _____ __________ _____ ______ ____ _________ ________ ________ _______ __________ _____.
____ _________ _________ _____ _______ ____ ______ __________ _________ _____ _________ ____.
______ _____ _____ ____ __________ _______ __________ _________ ___ ____ ____.
_____ ___ _____ ____ _____ __________ ______ ______.
_________ ____ _________ ______ ______ _____ _________ _________ _____ ____ _________.
_______ __________ __________ _____ __________ _____ _______ _______ ______ ________ ____.
_________ __________ ________ __________ ____ ___ ________ _____ ___ _______ ___.
_________ ________ _____ ___ __________ _________ ___ __________ __________ _______ ________.
______ ___ _______ _______ ____ ___ ________.
______ ________ __________ ____ _____ ________ _______ _______ ______ _________.
______ ___ ___ __________ ___ _______ _________ __________.
_____ ______ ______ _________ ____ _______ _________ _____ __________.
________ ______ _______ ______ ______.
____ ____ ___ _____ _____ ____ ___ _____ ______ __________ __________ _____.
______ __________ _________ __________ _______ _______ _________ _____.
____ ____ _____ __________ ______ ___ ________ _________ __________ __________ _________ ____.
______ _______ _______ _______ _______ _________.
_______ _____ ___ ______ ____.
_______ ___ ______ ____ ___ _______ _______ _______ _____ _____ _________.
_____ _____ ______ ____ ___ ______ _________ __________ ____ __________.
___ ______ ______ _________ _______ __________ __________ ________ ________ ___ ____.
_______ ______ ____ ______ _____.
__________ ___ ____ __________ ______ ________ __________ ______ _______.
___ _________ ________ ______ ________ _______ __________ _______ _________ _______ ___.
______ _______ ________ ____ _______ _________ ___.
__________ _____ ___ _____ ______ ____.
________ _________ ________ __________ ________.
_______ _____ ______ ________ ____ _________ ___ _______ ____ _____.
_______ ________ ___ ______ ____ ________ _______ _____.
____ __________ ________ _______ _________ _________ ____ _____.
____ _________ _____ _____ _____ ___.
____ ______ _______ _________ _______.
________ ________ ____ _________ _____ __________ __________ _________ ___ _______.
_______ ______ _____ __________ _____ __________ _______ _______.
__________ _________ _________ _________ ___.
_________ ______ ____ _________ _______ ______ _________ ______.
______ ________ __________ ________ ___ ____ _____ ______ ___.
____ ____ _______ _______ ____ ___ __________ _______ __________ ______.
______ ____ _____ _______ _________ _____ ________ __________.
__________ ____ __________ ____ _________ ________ _____ _____ ____ __________ _______.
_____ ______ ____ ____ _________ _________ _____ ____ __________.
________ ___ __________ _________ _____ ______.
__________ _______ _____ _____ __________ ___ _____ _______ _________ _____ _________.
___ __________ ______ _______ _____ _____ ___ ______ ______ ___ _____ __________.
_______ _________ ________ _____ _______ ____ ________.
__________ _____ _____ _______ _____ _______ ___ _________ ________ ________ ________ _______.
_______ __________ _______ ______ __________ _________ _____.
__________ ______ ____ ____ _______ ______ ______ _______.
_____ ___ _______ _________ ____ _______ _______ ___ ________ _________.
_________ ______ _______ ____ ________ _________ ______ ___ ____ ________ ____.
___ ________ ______ __________ ________ __________.
______ ____ ______ ______ _____ ___ __________ _____ ___.
________ ___ _________ ___ _________ _____ __________ ________ ________ ____.
_______ __________ _____ ______ _________ _______.
____ __________ ________ ________ _______ __________ ___ ____ ________ ____ _______.
___ _________ _________ __________ ______.
____ ______ ___ _____ ____ ________ ___ __________.
___ ______ ______ _____ _______ __________ _______ _____ ________.
____ __________ ______ __________ _______ _______ _______ _____ _____ _________ ______ ___.
_____ ________ ____ _________ _______ ___ ___.
IGNOU ACADEMY
Your IGNOU journey, made easier.
  • Solved Assignments
  • Study Notes
  • Guess Papers
  • Question Papers
Skip in 10
Top
📞
Call Support Instant phone assistance IGNOU MCS 201 2023 - Explain the concept of call by reference, with suitable code in C for | IGNOU Academy
→
🟢
WhatsApp Chat Fast live messaging
→
Email Us Business enquiries & support
→