pre- or post-increment(decrement) operators

Tuesday, October 14, 2014
/* 0602.c: pre- or post-increment(decrement) operators */
#include <stdio.h>

main()
{
    int w, x, y, z, result;

    w = x = y = z = 1; /* initialize x and y */
    printf("Given w = %d, x = %d, y = %d, and z = %d,\n", w, x, y, z);

    result = ++w;
    printf("++w gives: %d\n", result);
    result = x++;
    printf("x++ gives: %d\n", result);
    result = --y;
    printf("--y gives: %d\n", result);
    result = z--;
    printf("z-- gives: %d\n", result);
    return 0;
}

Copyright @ 2015 Tron!

Labels

Blog Archive