Moamen
Moamen

Reputation: 1

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

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

Upvotes: -2

Views: 87

Answers (1)

Dark Rebellion
Dark Rebellion

Reputation: 234

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.

Upvotes: 0

Related Questions