What will be the result of the following two expressions if i=10 initially?a.++i<=10,b.i++<=10
Answers
Answered by
0
Answer:
This expression is invalid in C. Prefix or postfix increment on a variable implies “add 1 to i”. And as you would be aware, prefix operation first increments the variable and then the expression is evaluated while postfix increments after the expression is evaluated.
Coming to the error, the compiler will complain saying, there is no valid lvalue for the operation. lvalue means a reference to a C object(variables). To see why this error occurs, you can think the increment operation as funtions that do not return references to C like objects.
Explanation:
int x = 10;
x = 10 + ++x; //prefix increment
int y = 10;
y = 10 + ++(y++);
Similar questions