Question: Consider the following C++ code: int main() { int i = 17; int k = 31; int &j = i; cout < < k =

Consider the following C++ code:

int main() { int i = 17; int k = 31; int &j = i; cout << "k = " << k<< " i = " << i << " j = " << j << endl; j = k; cout << "k = " << k<< " i = " << i << " j = " << j << endl; } 

The output of our program is:

k = 31 i = 17 j = 17 k = 31 i = 31 j = 31 

Explain the flow of the program and why the output appears as it does.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!