Simple but Nagging Question HELP!
I am completely new to programming and I have a elementary question about how to test for an even number. I understand that ((n%2)==0) tests this--because the number needs to be divisible by 2--but I don't understand why the boolean expression ==0 works, e.g 2%2 is not = to 0. I understand that == is a boolean expression, but the book I'm learning from explains it as still evaluating for equality, but provides either true or false as a value. What am I missing? I'm guessing that it has something to do with the remainder from the division being equal to 0, but I don't really understand why that would be? I've tried it using both int vars and double vars. Could someone please explain this to me? I've asked all of my programmer friends at work, searched the internet, and no one has given me a reasonable answer.