# Assignment Operator in C Language | L- value Error in C programming

## Introduction:

In our previous articles, we discussed the Arithmetic Operators in C Language. In todayâ€™s article, We will learn about the Assignment Operator in C Programming. We also discuss the L-Value error in programming.

## Assignment Operator in C Langauge ( = ) :

The C programming language has assignment operators to create and assign values to the variables.

We represent the Assignment operator using the equal to( = ) symbol in C programming.

### Syntax Of Assignment Operator:

The assignment operator is for used assigning values. In general assignment operator assigns the value of the right-hand ( R-Value) side operand to the Left-hand (L-Value) side Operand.

The assignment operator is a binary operator so it must need two operands.

The assignment operator has two values. The Left-side value is called as L-Value and The Right-side value is called as R-Value.

The Assignment Operation will copy the R-Value to L-Value.

The left-side value ( L-Value ) of the Assignment Operator must be a Variable.

The assignment operator has the Lowest Precedence or Priority compared to all other operators except Comma Operator.

For full Priority of Operators please visit â€“ see full priority table/precedence tableÂ

## Example Program to understand Assignment Operator:

In above Example x = 10 is assignment operation.

Here x is the left-side value or L-Value and The value 10 is the right-side value or R-Value, By using the assignment operator we assigned the value 10 to the variable x.

#### Program Output:

As you can see the value of x is 10.

## Example 2 : L â€“ Value Error in C programmingÂ :

The Left-side value of the Assignment Operator must be Variable. So we basically trying to assign R-Value to L-Value. So L-Value must-have capacity to store the R-Value. But constants and numbers canâ€™t store a value.

ðŸ“¢ The Left-side or L-Value of the Assignment Operator must be a Variable.

## Complex Assignment Operations in C Programming:

In the C programming language, We have few compound assignment operators to perform the assignments along with some other arithmetic operations.

For example,

x = 5; // simple assignment

x += 10; // compound operation

### Simple Assginment Operation:

x = 10;

This is a simple assignment, Here we have created a variable x and assigned value 10 to x.

x += 20;

This is a compound operation. Which is equal to

x = x + 20;

Here first x+20 is calculated then x is updated with the resulting value of x+20 operation.

Similarly, we can have other compound arithmetic operations, Please look at the following table for all compound Operations.

The Compound Assignment statements are elegant and try to use them in the programs.

## Conclusion:

In this article, We discussed the Assignment Operators and Compound Assignment operators in the C language. We also looked at a few example code snippets and L-Value Error.

## Related Programs:

Venkatesh

Hi Guys, I am Venkatesh. I am a programmer and an Open Source enthusiast. I write about programming and technology on this blog.