+=(relation) the meaning of code for selection process

82 Views Asked by At

counter += (a1<=x);

what this code statement says ?

it is used in a problem to get how many numbers is lower than or equal (x) variable,

this should be as comparison between a1 and a2 to get what is less than or equal variable x

1

There are 1 best solutions below

6
Dark Rebellion On

It feels like an unnecesssarily complicated way of saying:

if(a1 <= x) counter++;

If we are to believe that "true" defaults to "1" and "false" defaults to "0" when converting boolean to int.