What is the Lvalue and Rvalue?

Answer Posted / vadivel t

Simple definitions:

Lvalue - is value which can be modified(it cannot be a
constant). And it can act as Rvalue too.

Rvalue - is value which can be able to fetch from the
memory, propably a constant. It can also act as Lvalue(if
it is not a constant).

Dont be confused... Lets hav example.

Example:
int a = 0, b = 10;

1.Rvalue
if(a)
{
...
...
...
}

here a is RValue(cos, as per definition, the value is able
to fetch from the memory)

2.One variable acting as L and R value
a = a + b;

here a + b; evaluated fist.. lets analise...
First a and b has to be fetched from the memory, by this
time, both will act as a Rvalue(as per definition)....
then a + b result shall be assigned to 'a'. Now 'a' will be
acting as a Lvalue. Cos u able to modify it...

So here 'a' can act as L as well as R value depends on the
situation.

3.a = 10;

Here 10 is Rvalue and 'a' ll act as Lvalue.
Hope u understand clearly.

Is This Answer Correct ?    6 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What does emoji p mean?

600


Explain what is the general form of a c program?

622


What is the use of typedef in structure in c?

544


How to compare array with pointer in c?

621


console I/O functions means a) the I/O operations done on disk b) the I/O operations done in all parts c) the input given through keyboard is displayed VDU screen d) none of the above

655






What is static and volatile in c?

779


Is exit(status) truly equivalent to returning the same status from main?

585


Explain how do I determine whether a character is numeric, alphabetic, and so on?

652


Explain void pointer?

589


What is I ++ in c programming?

624


What is stack in c?

612


What is the difference between #include

and #include “header file”?

552


Where are some collections of useful code fragments and examples?

716


what is the c source code for the below output? 5555555555 4444 4444 333 333 22 22 1 1 22 22 333 333 4444 4444 5555555555

2533


What are the different types of errors?

643