> expecting to work in such way if while ans is not equal to n OR N continue
> so with || operator i was expecting if at least one condition is true break
¿break or continue? decide yourself.
make a true table
ans a = ans!='n' b = ans!='N' a or b a and b
'n' 0 1 1 0
'N' 1 0 1 0
'y' 1 1 1 1
¿can you imagine a value for ans so that both `a' and `b' are false?
just to check I am not making basic mistake,
false = 0 True = 1 correct?
I wanted to break from the loop when one of the condition is met ie. if ans is equal to lower case or upper case N.
so if users types n loop will break, if user types N loop will break. If user types anything else loop will happily continue.
but in your example you if I understand it correctly is the other way round :/
ps I find confusing/annoying true and false arguments. above example
if ans is not equal to zero is True, otherwise is false so its zero. On the other hand if program finish successfully it return 0.
> I wanted to break from the loop when one of the condition is met
> ie. if ans is equal to lower case or upper case N. ans != 'n' || ans != 'N' does not mean «if ans is equal to lower case or upper case N»
for that you need to write ans == 'n' or ans == 'N'
however, to exit the loop you need the condition to be false, so negate it not (ans == 'n' or ans == 'N')
> ps I find confusing/annoying true and false arguments. above example if ans
> is not equal to zero is True, otherwise is false so its zero. On the other
> hand if program finish successfully it return 0.
I have no idea what you are talking about.
Try to rephrase it.
De Morgan Law - never came across it (however during my school years its possible it was explained but without explicit name)
In my last section it was just remark that its confusing use of True and false in c++ as not always 0 is false and 1 true. (example I have used when program terminates with return 0 it is considered success)
Example: I have used when program terminates with return 0 it is considered success.
Don't get confused by this: your program returns an error code. That is, it answers the question "what error occurred?", and in a Boolean context, consequentially "was there an error at all?".
This is generally consistent, but IMO it makes more sense if you think about return 0 not as "return success" but as "return no error" or "I have no error to describe" or "I did not fail".
@mbozzi - that is actually a great explanation! simple but to the point. thank you :)
@TheIdeasMan - that sounds interesting :) I will explore toupper and tolower!
on other hand I do appreciate your words but at learning stage you have no idea what is ugly or pretty constructor. :D you barely know that there is a constructor ;)