हिंदी

Explain call by reference with a suitable example. - Structured Programming Approach

Advertisements
Advertisements

प्रश्न

Explain call by reference with a suitable example.

Explain call by reference with an example.

स्पष्ट कीजिए
Advertisements

उत्तर

  1. In call by reference, when a function is invoked, the addresses of the actual arguments are passed to the formal parameters, meaning both refer to the same memory location.
  2. As a result, any change made to the formal parameters directly affects the values of the actual arguments.
  3. The variables modified inside the function are returned to the calling program with their updated values.
  4. For example:
    void swap(int &a, int &b)
    {
        int temp = a;
        a = b;
        b = temp;
    }
shaalaa.com
  क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
2018-2019 (December) CBCGS
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Course
Use app×