Tuesday, February 4, 2014

simple program help


The problem is in your if-statement: "max > 4 || max <= 10"


Consider my input: 3. Is it > 4? False! Is it <=10? True! So the condition is true since false || true == true.

Consider my input: 13. Is it > 4? True! Is it <=10? False! So the condition is true since true || false == true.


Replace the || with && and it will work as false && true == false.



No comments:

Post a Comment