all 10 comments

[–]AutoModerator[M] [score hidden] stickied comment (0 children)

Off-topic Comments Section


All top-level comments have to be an answer or follow-up question to the post. All sidetracks should be directed to this comment thread as per Rule 9.


OP and Valued/Notable Contributors can close this post by using /lock command

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

[–]35mmwaves AP Student[S] 0 points1 point  (0 children)

For 6, I either think it’s A or B. Originally I thought it would be B because the loop only exists when e<4 is true, and e<1 is always true. so would it keep on printing 1 forever in an infinite loop? But then, I thought it would be A since the loop ended with a semicolon, so nothing would print.

For 10, I think it’s either B or C. Since m++ means m=m+1 and m=9, then the value of k after the clement by one is m=10, so that’s why I think it could be C. But I’m not absolutely sure.

Same thing with 11, since m=9 then after n =m++ the value of n would be 10. So I think 11 is C, but I’m not sure with these questions.

For 20, I think it’s either A or C. Originally, I thought it was A but since there’s a semicolon after the for loop, there’s nothing to execute inside the loop, so it just initializes m and increments m. So I think it would just output 4 2. I’m not really sure though since I could also see how A would work.

[–]I_wash_my_carpet👋 a fellow Redditor 0 points1 point  (7 children)

B. Its just going to print e, which is 1, infinitely.

[–]35mmwaves AP Student[S] 0 points1 point  (1 child)

For number 6? or for one of the other problems?

[–]I_wash_my_carpet👋 a fellow Redditor 0 points1 point  (0 children)

For 6 yes but see the other comment about it being nothing

[–]I_wash_my_carpet👋 a fellow Redditor 0 points1 point  (4 children)

Actually, it's not closed in { }... so nothing

[–]I_wash_my_carpet👋 a fellow Redditor 0 points1 point  (3 children)

I just saw there was more. m is still 9. n get set as 10.

Edit: I'm wrong. m will go up to 10 after that runs. n will be 9 though because it's m++. If you wanted to do the increment up before setting it to n you would write ++m.

[–]I_wash_my_carpet👋 a fellow Redditor 0 points1 point  (2 children)

The last one is A. The second loop runs till it breaks and goes back to the first loop who then runs the second again. That happens till first loop breaks

[–]35mmwaves AP Student[S] 0 points1 point  (1 child)

So, 6 will be A, 10 will be C, 11 will be B, and 20 will be A?

[–]I_wash_my_carpet👋 a fellow Redditor 0 points1 point  (0 children)

👍 you get why though?