# Compound Assignment

Note that Compound assignment to an enumerated type generates an error message.

If the left operand is of a pointer type, the right operand must be of a pointer type or it must be a constant expression that evaluates to 0.

Each compound-assignment operator performs the conversions that the corresponding binary operator performs and restricts the types of its operands accordingly.In this chapter and the next, we present the theory and principles of structured programming with control statements.We introduce the control and use it to display and process data, such as a list of grades in a class-average program.That information, along with your comments, will be governed by DISQUS’ privacy policy.By commenting, you are accepting the DISQUS terms of service.One of the reasons compound operators are useful is that not only they provide a shorter way for operations, but also implicitly cast variables.Formally, a compound assignment expression of the form: Let’s review why the last line won’t compile.It is very common to have an assignment statement only involving one operation and two values where the result replaces the original value, such as: a = a 3; b = b * c; C and C offer several convenient shortcuts to such statements. The above two assignments may be replaced by: a = 3; b *= c; The = and *= are two of many instances of compound assignment operators. The operator ' ' does the binary numeric promotion to its operands, using Widening Conversion to convert operands as necessary. "short y =1; y = y 1;" doesn't compile is because of the so called Binary Numeric Promotion.For y = y 1, is int, so y is converted to an int, the result of y 1 is also of type int.

## One thought on “Compound Assignment”

1. To begin with, I agree with the statement that education should start at early ages, because children can learn easily while growing up.

2. You should have at least three paragraphs’ worth of evidence for your argument, and if you do not, it’s likely that your thesis isn’t strong enough.

3. He’s got black hipster glasses, a stubble beard and, as usual, his forehead is wrapped in his trademark black paisley bandana (a habit borne out of a need to keep his hearing aid dry).

4. You might make a list of all the reasons you want to get the Ph. You might plan out your life’s possible courses for the next 2, 5, 10, or 20 years if you do and if you don’t proceed with the degree.