102Views3Replies

Author Options:

Coding question Answered

In this line of code the N and Y have single quotation marks around them, what do they do?

 if (goodOne == 'N' && buttonPushed == 'Y')

Comments

The forums are retiring in 2021 and are now closed for new topics and comments.
0
frollard
frollard

Best Answer 8 years ago

As Jayefuu suggests, its asking if the values of goodOne is literally the character 'N' - not yes, not no, not true, not false, not 1, not zero, but the character N. If it is N, and buttonPushed is Y, then it will evaluate true, and the if statement will execute.

0
WWC
WWC

Answer 8 years ago

I would say this answer is closest to fitting in with this sketch.
Thanks

0
WWC
WWC

8 years ago

Thank You to all that took you time to respond.
It seams the answer is not cut and dry to this single quotation " command ".
Even when i research this on Google i get 4 different answers to 4 searches. So i think it depends on how, why and what also for the code. Beings how i did't provide the rest of the code the answers will be different.

0
Jayefuu
Jayefuu

8 years ago

Tells the compiler to evaluate it as a string, I think. Take the quotes out, try to compile it and then look at the error it gives you, that might give a better explanation.