Advertisements
Advertisements
Questions
Explain call by value with an example.
Explain call by value with a suitable example.
Explain
Advertisements
Solution
- When a function is called by a part of the program, control is passed from the main program to the called function, and the values of actual arguments are copied into the function.
- Inside the function, these copied values may be modified or changed.
- When control returns from the function to the calling program, the modified values are not reflected back in the original arguments. This method of passing arguments is known as call by value.
- For example:
main () { void funct (int X, int Y); ........ funct (X, Y); // Call by value ........ } void funct (int a, int b) { ........ }
shaalaa.com
Domain and Range of a Function - Passing Arguments to a Function
Is there an error in this question or solution?
2018-2019 (December) CBCGS
