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'
>>61559961
this can be rewritten asdo{ 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 realwhile (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.
>>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
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"""".