The basic assignment operator in C is =
. It assigns the value on the right side of the operator to the variable on the left side.
Chained assignment allows you to assign the same value to multiple variables in a single statement. For example: a = b = c = 10;
.
Compound assignment operators combine an operation with assignment. Examples include +=
, -=
, *=
, /=
, and %=
.
+=
work in C?The +=
operator adds the right-hand operand to the left-hand operand and assigns the result to the left-hand operand. Example: a += 5;
is equivalent to a = a + 5;
.
Assignment (=
) assigns a value to a variable, while comparison (==
) checks if two values are equal.
Pre-increment (++a
) increments the variable before using it in an expression, while post-increment (a++
) uses the variable first, then increments it.
No, you cannot assign a value to a constant after it has been declared with const
. Doing so will result in a compilation error.