C language basics 1 -
what difference between a++ , a=a+1 in c if variable. tell me difference between following assignments;
x=a+1; x=a++;
i not able find convincing explanation on google.please explain difference , step step.
a = a+1;
calculates result of a+1
, assigns a
.
a++;
increments a
1
, evaluates previous value of a
.
++a;
increments a
1
, , evaluates new value of a
.
a += 1
identical ++a;
.
so example:
x = a++;
→ a
incremented 1
, , previous value of a
assigned x
.
x = ++a;
→ a
incremented 1
, , new value of a
assigned x
.
Comments
Post a Comment