Why this program is returning 10 as the value of j after assigning it to k ? where as k=12 [closed]

Erroneous code:

// k = 12, j = 10
k = j; // k => 10
j = k; // j => 10

Use the operation below if you want to swap the values of k and j:

// k = 12, j = 10
k = k + j; // k => 22
j = k - j; // j => 22 - 10 => 12
k = k - j; // k => 22 - 12 => 10

Browse More Popular Posts

Leave a Comment