This browser is no longer supported.

Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.

C Assignment Operators

  • 6 contributors

An assignment operation assigns the value of the right-hand operand to the storage location named by the left-hand operand. Therefore, the left-hand operand of an assignment operation must be a modifiable l-value. After the assignment, an assignment expression has the value of the left operand but isn't an l-value.

assignment-expression :   conditional-expression   unary-expression assignment-operator assignment-expression

assignment-operator : one of   = *= /= %= += -= <<= >>= &= ^= |=

The assignment operators in C can both transform and assign values in a single operation. C provides the following assignment operators:

In assignment, the type of the right-hand value is converted to the type of the left-hand value, and the value is stored in the left operand after the assignment has taken place. The left operand must not be an array, a function, or a constant. The specific conversion path, which depends on the two types, is outlined in detail in Type Conversions .

  • Assignment Operators

Was this page helpful?

Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see: https://aka.ms/ContentUserFeedback .

Submit and view feedback for

Additional resources

IMAGES

  1. Assignment Operators in C with Examples

    assignment operators in c programming with examples

  2. C programming +=

    assignment operators in c programming with examples

  3. Operators in C

    assignment operators in c programming with examples

  4. Assignment Operators in C/C++

    assignment operators in c programming with examples

  5. C Programming Tutorial

    assignment operators in c programming with examples

  6. Operators in C

    assignment operators in c programming with examples

VIDEO

  1. Assignment Operators in C

  2. C_14 Operators in C

  3. Assignment Operator in C Programming

  4. #6: C Operators

  5. C_18 Operators in C

  6. C_13 Operators in C

COMMENTS

  1. Assignment Operators in C with Examples

    The += assignment operator is a combination of + arithmetic operator and = simple assignment operator. For example, x += y; is equivalent to x = x+y;. It adds the right side value to the value of left side operand and assign the result back to the left-hand side operand. #include <stdio.h> int main () { int x = 100, y = 20, z = 50 ...