0

What is the difference between post increment and pre increment in C programming ??

3rd Dec 2017, 4:35 AM
Aman Jain
Aman Jain - avatar
3 ответов
+ 1
Try the C++ course. It reviews post and prefix https://www.sololearn.com/Course/CPlusPlus/?ref=app
3rd Dec 2017, 5:05 AM
Manual
Manual - avatar
0
Post Increment: a = 10; b = 2; c = b + a++; printf("c = %d", c); printf("\na = %d",a); Output: c = 13 a = 11 As you just saw in post increment the old value of variable 'a' is considered and after the value of 'c' is stored, then 'a' is incremented. Pre Increment: a = 10; b = 2; c = b + ++a; printf("c = %d", c); printf("\na = %d",a); Output: c = 14 a = 11 Here, the value of 'a' was incremented already while the operation was performed. So, Post Increment first stores the value in temporary buffer then increments it, while Pre Increment increments it then returns it.
3rd Dec 2017, 4:54 AM
Rachit Mishra
Rachit Mishra - avatar
3rd Dec 2017, 5:00 AM
Nanda Balakrishnan