Examples of the Increment and Decrement Operators
/** examples of the increment and decrement operators **/
int main(void)
{
int x,y;
x=5;
/** prefix increment **/
y = ++x;
printf("++x: x=%d, y=%d\n", x, y);
x=5;
/** postfix increment **/
y = x++;
printf("x++: x=%d, y=%d\n", x, y);
x=5;
/** prefix decrement **/
y = --x;
printf("--x: x=%d, y=%d\n", x, y);
x=5;
/** postfix decrement **/
y = x--;
printf("x--: x=%d, y=%d\n", x, y);
return 0;
}
|