Good evening everyone.
I came up with the answer 25 for the below question/code. Since J is holding the value of 0 and k = 50, k is greater than 0 thus j + k = 50 and k / 2 is 25. Am I in the ballpark or am I still out in the parking lot on this one?
Let j and k be two int variables. Trace the execution of the following for loop by showing the values of j and k at the end of each iteration (i.e., immediately after the update part is executed):
for (j = 0, k = 50; k > 0; j += k)
k /= 2;
I came up with the answer 25 for the below question/code. Since J is holding the value of 0 and k = 50, k is greater than 0 thus j + k = 50 and k / 2 is 25. Am I in the ballpark or am I still out in the parking lot on this one?
Let j and k be two int variables. Trace the execution of the following for loop by showing the values of j and k at the end of each iteration (i.e., immediately after the update part is executed):
for (j = 0, k = 50; k > 0; j += k)
k /= 2;
Comment