Lvalue is also known as locator value which always refers to an object. Here the object is named region of storage. In simple words, an Lvalue is an identifier that has a type and storage class that yields some address location. In the case of Rvalue, they cannot as they simply have a value that can be assigned to an lvalue.
Examples of Lvalues:
Variables, Arrays, pointer variables, structure or union e.t.c
Example of Rvalues:
For all constants, the function returning a non-reference value is referred to as R-value.
Remember, R-values don’t have any storage space associated with them.
Example program to demonstrate Lvalue & Rvalue
#include <stdio.h>
int main(){
int a;
a = 10;
printf("%d", a);
}
In the above example, a is an Lvalue because it has the valid type int and also a storage class “auto” associated with it.
10 is referred to as an Rvalue because it is an integer constant & no address/storage space is associated with it.
References:
Appendix A, Section A.5 Objects and Lvalues in the book “The C programming language 2nd edition” written by Brian Kernighan and Dennis M Ritchie.