# Increment and decrement operator

Int main()
{
a=10;
a=a++;
a=a++ * a--;
print("%d",a);
}
I don't get why the output is 110 plz explain the output

## Comments

• First off, your code is not even valid C.
Now translation of your code:

``````a = 10
a = 10
a = 11 * 10
``````

For why that is go read some about sequence point.

• Hey boo ,sorry I didn't mention that a is int data type, but u didn't explain it well why in last line it's 11*10

• What do you expect it to be? On line 2 assignment precedes the increment. On line 3 it's an expression so increment/decrement need to be evaluated first before both numbers are multiplied.
Maybe this will be more clear:

``````a = 10
(a = a + 1) * (a = a - 1) // a++ * a--
``````
• Assignment operator preceds the increment. Moreover, the value of a is initialised to be 10 and then multiplied with 11 which gives the result 110. For help on operators in C, follow the link : http://knowledgetpoint.com/csharp/csharp-language-fundamentals/

Sign In or Register to comment.

#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!