[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

do{ shit(); } while (x != 'y' && x != 'n');

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 21
Thread images: 4

File: IMG_0864.jpg (39KB, 640x480px) Image search: [Google]
IMG_0864.jpg
39KB, 640x480px
do{ shit(); } while (x != 'y' && x != 'n');


please explain: how can x be not equal to y AND n.
what if x is n then first test fails and assumingly do while should fail and loop again.
>>
>how can x be not equal to y AND n.
Let x be 'p'.
'p' is not 'y', nor is it 'n'.
Therefore x is not 'y', nor is it 'n'.

>what if x is n then first test fails and assumingly do while should fail and loop again.
Well, that's what makes a do/while loop different from a regular loop. The first iteration is executed regardless of whether the condition would be satisfied or not, and during that iteration, things might change that would cause the condition to be satisfied where it was not previously.
>>
The loop will keep going so long as x isn't equal to 'y' or 'n'.
Why is that so hard to understand?
>>
>>61560059
>or
are you blind? && is and.
to me it makes more sense to have || instead of && in there.
>>
>>61560127
ok

The while loop can only continue so long as x IS NOT EQUAL TO 'y' AND x is NOT EQUAL TO 'n'.

Is that hard to understand?
>>
>>61560127
If ||, it won't short circuit if x == 'y'
>>
File: 1500357566041.jpg (44KB, 540x545px) Image search: [Google]
1500357566041.jpg
44KB, 540x545px
>>61559961
this can be rewritten as
do{ shit(); } until (x == 'y' || x == 'n');


hopefully this makes things clearer for you
>>
>>61560127
>are you blind? && is and.
I hope you realize that !(A && B) == !A || !B, which is what he basically did, in text.
>>
>>61560153
retard. how can x not be equal to 2 things at once?
>>
>there are literal retards who went to uni to learn formal logic
>this is the result
is there anything more useless?
>>
>>61560215
You're the one retarded if you don't grasp basic logic.
>>
>>61560214

De Morgan's theorem might be a little bit over OP's head
>>
>>61560215

So what you're saying, sir, is that I must either be the President of the United States or the Secretary of State, and cannot in any way be neither?
>>
nvm. fixed it ;)
>>
here's the loop in java just for the sake of being real
while (x != 'y' && x != 'n') {
doShit();
}

So saying x (a variable that can store anything_ equals 'f' the function doShit() will run, if x is equal to 'y' or 'n' the function doShit() will not run.
>>
>>61561281

It's a do while loop, not a while loop.
>>
File: thiskillsthecrab.jpg (24KB, 430x358px) Image search: [Google]
thiskillsthecrab.jpg
24KB, 430x358px
>>61560215
i can equal 2 things at once, or 12 things at once, or 50,000 at once. BUT so long as its not 'y' or 'n', 'while' will be run. is that hard?
>>
>>61559961
yep the loop can't end
>>
>>61560215
Give up on computer science
>>
File: Patrick-hooks.jpg (87KB, 400x300px) Image search: [Google]
Patrick-hooks.jpg
87KB, 400x300px
do-while runs at least once.
>>
>>61560215
not equal = different
How can something be different to two other things????? Are we living in a world with only two things????????????????

Let me guess, you want to learn web """"programming"""".
Thread posts: 21
Thread images: 4


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.