 
                 
                InterviewSolution
| 1. | Explain with example by passing the reference. | 
| Answer» #include <iostream> swap(a, b); The output of the above program is: In C++, reference variables are possible and works like alias to original memory locations. In the above program, the function void swap(int& x, int& y); is declared with two arguments with x and y as reference variables. During the function call swap() takes two arguments (formal arguments) ‘x’ and ‘y’ which are reference variables to variables of actual arguments ‘a’ and ‘b’ respectively. The interchange of value takes place between x and y in the body of swap() function. Here, variable ‘x’ and ‘y’ are used to manipulate the data values from the location ‘a’ and ‘b’ directly. | |