WAP to demonstrate the use of reference variables using c++?

#include <iostream>
using namespace std;
 
int main()
{
    int a=10;
 
    /*reference variable is alias of other variable, 
    It does not take space in memory*/
 
    int &b = a; 
 
    cout << endl << "Value of a: " << a;
    cout << endl << "Value of b: " << b << endl;
 
    return 0;
}

The output of the above variable is

Value of a: 20
Value of b: 20
If you found any type of error on the answer then please mention on the comment or report an answer or submit your new answer.
Leave your Answer:

Click here to submit your answer.

s
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments