I'm new to programming
if( (N%2==0) && (6<=N<=20) )
Throws the error below
The operator <=
is undefined for the argument type(s) boolean
, int
Please help me fix it.
You can't compound the statement like that. You need to &&
it.
For example,
if ((N % 2 == 0) && (6 <= N && N <= 20)) {...}
The reason you get the error is the first condition of 6 <= N
resolves to a boolean
and you then attempt to check if a boolean
is <=
to an int
. That does not compute.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With