If you have any query feel free to chat us!
Happy Coding! Happy Learning!
In C programming, assignment operators are used to assign values to variables. Here are the most common assignment operators used in C:
= : assignment operator. It assigns the value of the right operand to the left operand.Copy code
int x = 5, y;
y = x;
This will assign the value of x (5) to y.
+= : addition assignment operator. It adds the value of the right operand to the value of the left operand and assigns the result to the left operand.Copy code
int x = 5, y = 3;
x += y;
This will add the value of y (3) to x (5) and assigns the result to x, resulting in x = 8.
-= : subtraction assignment operator. It subtracts the value of the right operand from the value of the left operand and assigns the result to the left operand.Copy code
int x = 5, y = 3;
x -= y;
This will subtract the value of y (3) from x (5) and assigns the result to x, resulting in x = 2.
*= : multiplication assignment operator. It multiplies the value of the left operand by the value of the right operand and assigns the result to the left operand.Copy code
int x = 5, y = 3;
x *= y;
This will multiply the value of x (5) by the value of y (3) and assigns the result to x, resulting in x = 15.
/= : division assignment operator. It dividesStart the conversation!
Be the first to share your thoughts
Quick answers to common questions about our courses, quizzes, and learning platform
Didn't find what you're looking for?
Contact Support