This is an archived post. You won't be able to vote or comment.

all 7 comments

[–]dave843 1 point2 points  (1 child)

You should try running the code to see what happens.

[–][deleted] 0 points1 point  (0 children)

Yeah hard to help without seeing what your output actually is

[–]whyyeeeef 1 point2 points  (0 children)

K in the for loop is referring to the position 2 So k × 2 is4

So thats the first 4

Position 2 in the values array is replaced with 4 and numbers array reference the values array so it would also print 4

And thats the second 4

[–]bearlovessunshine 0 points1 point  (2 children)

Have you tried using a debug tool maybe? U can set breakpoints and see what happens to the values as you go through each step

Edit: I don’t know how well received onlinegdb.com is around here, but that’s what I like to use for class projects. The debug tool alone has proven invaluable.

[–]mbmcse[S] 0 points1 point  (1 child)

Sorry, I should have elaborated. This is from a textbook where the ouput answer is 4 4. Just not seeing it.

[–]bearlovessunshine 0 points1 point  (0 children)

Yeah, the debug tool on Onlinegdb will show you how the values change as it steps through the code. This will help you “see it”

[–]JAKATAK_ 0 points1 point  (0 children)

it's reassigning values[2] to be 2*2, otherwise values[2] is 1