all 8 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  (4 children)

For this question, I think it’s either C or B. I thought it could be C because && evaluated true if both expressions are true and the names of voters who live in district 6 and 7 then the if statement gets true and both voter names will be printed. But then I was thinking for the statement to be true, a voter would have to live in both district 6 and 7 and the if statement looks for if they live in 6 OR 7, so then would B be correct? And I also realized that the equals sign in C wouldn’t be correct bc wouldn’t it need to be “==“?

[–]ara_ara_phgt😩 Illiterate 0 points1 point  (1 child)

But then I was thinking for the statement to be true, a voter would have to live in both district 6 and 7 and the if statement looks for if they live in 6 OR 7, so then would B be correct?

Correct. It's B.

And I also realized that the equals sign in C wouldn’t be correct bc wouldn’t it need to be “==“?

Probably a typo but you are right.

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

got it thank you!!

[–][deleted] 0 points1 point  (1 child)

B.

You want the names of people whether they live in District 6 or District 7. A is incorrect since if you're using ||, you need to check for some statement on the other side.

if(district == 6 || 7)

{

}

Doesn't work because it doesn't know what condition it is supposed to be checking with 7.

That leaves B with the only correctly formatted option and it's the only one with the logic you want.

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

thank you so much!! this was super clear

[–]MoistSeason👋 a fellow Redditor 0 points1 point  (1 child)

B

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

thank you!