101k views
4 votes
Consider the following code snippet.

x = 7;

y = x;

z = x;

z = 5;


What is the value of variable y at the end?


Select one:


a. 7

b. These equations do not have a solution.

c. 5

Your help is a big time saver.

User Shivg
by
7.2k points

1 Answer

5 votes

Answer:

The value of variable y at the end is 7.

This is because the first line sets the value of variable x to 7. The second line assigns the value of x (which is 7) to y. The third line also assigns the value of x (which is still 7) to z. The fourth line assigns the value 5 to z, but this does not affect the value of y, which remains 7 since it was never changed.

Step-by-step explanation:

User N Kumar
by
7.6k points