1. The difference between post-increment and pre-increment
Source: http://www.c4learn.com/c-programming/c-increment-operator/
#include <stdio.h>void main () {int a,b,x=, y== x + + = + +y;printf ("Value of a:%d", a);p rintf (" Value of B:%d " , b);}
Different Types of Increment operation
In C programming we have a types of increment operator i.e pre-increment and post-increment operator.
A. Pre Increment Operator
Pre-increment operator is used to increment the value of variable before using the expression. The pre-increment value is first incremented and then used inside the expression.
b = ++y;
In this example suppose the value of variable ' y ' are 5 then value of variable ' B ' would be 6 because the value of ' Y ' gets Modified before using it in a expression.
B. Post Increment Operator
Post-increment operator is used to increment the value of variable as soon as after executing expression completely in whi Ch post increment is used. In the Post-increment value was first used in a expression and then incremented.
b = x + +;
In this example suppose the value of variable ' x ' are 5 then value of variable ' B ' would be a 5 because old value of ' X ' Is Us Ed.
C + + Learning notes-continuous updates during graduate studies