What do 'lvalue' and 'rvalue' mean in C/C++?

'lvalue' and 'rvalue' in C/C++ programming language: Learn, in an expression what do 'lvalue' and 'rvalue' mean?

Consider the following expression:

result=(a+b);

lvalue

An "lvalue" is an expression, variable, constant etc which appears at left-hand side of an assignment operator.

In the expression result =(a+b); - result is an "lvalue".

rvalue

An "rvalue" is an expression, variable, constant etc which appears at right- hand side of an alignment operator.

In the expression result =(a+b); - (a+b) is an "rvalue";

Consider the following expression, which is also a valid "lvalue" assignment.

((a+b)? a:b) =10;

In the expression, either a or b will be the result of "lvalue" expression and 10 can be assigned in a or b. so this expression is also a valid expression.

C Language Tutorial »





Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.