Assignment Operators in C

This “Assignment Operators in C” post is providing information about assignment operator including, syntax to use, locations to use and errors in case of violations with suitable examples.


Assignment operator :

  • C-language supports only one Assignment operator that is “=”.
  • Assignment operator always executes the data which is placed right side to it first, and the result will be assigned to left side variable.

Syntax :
<variable> = <data>;


The data may be
1. a value
2. a variable.
3. an expression
4. a method call.


int a,b,c,d;
a = 10; //value
b = a ;  //variable
c = a+b ; //expression
d = sizeof(c) ; //method call


Note : We cannot place a value to the left side of Assignment operator.
10 = a ; –> Error : LValue required


Note : Multiple Assignments are allowed in the initialization of variable.
int a = b = 10 ;

Share this