You can find multiple answers on SO describing what an lvalue is (an expression that designates an object, as opposed to merely a value), and that address other instances of "lvalue required" errors. For example,
Basically, the error means that the program contains an assignment or combined operator / assignment expression whose left-hand operand does not designate an object, such that the assignment part is nonsense.
Sometimes these arise because operator precedence yields a different order of operations than the author of the code supposed or wanted, and unless the code you presented is intentionally erroneous, that's the case with it. Specifically, in
float f = y + x /= x / y;
, the problem is with the initializer expression, y + x /= x / y
. Presumably, the intention was that this would be evaluated as y + (x /= (x / y))
, which has a well-defined value and a well-defined side effect on the value of x
.
However, the precedence of the assignment and opassignment operators such as /=
is very low, so the expression is actually interpreted as equivalent to (y + x) /= (x / y)
. y + x
is not an lvalue (it can be evaluated, but it does not designate an object), therefore it is not an acceptable left operand of the /=
operator. This is the reason for the error.
Your second question involves another operator precedence issue. The &&
operator has lower precedence than the ==
operator, so x && y == 1
is equivalent to x && (y == 1)
. With your initializations, the right-hand operand of &&
evaluates to 0, so the overall expression evaluates to 0. If the intention was to test whether x && y
evaluates to a truthy value, then this is a case of shooting oneself in the foot, because leaving off the == 1
part would both be more conventional and yield the desired result.