C/prefix and postfix
From ATI public wiki
Revision as of 17:50, 7 October 2015 by Marek (Talk | contribs) (C operator pre and postfix form difference)
/*
This example demonstrates the difference in using
prefix or postfix form of increment and decrement operators
*/
#include <stdio.h>
int main(int argc, char * argv[])
{
int i,j;
i=15;
j=15;
printf("I= %d , J= %d \n\r", i, j);
printf("-------------\n\r");
printf("I= %d , J= %d \n\r", ++i, j++);
printf("-------------\n\r");
printf("I= %d , J= %d \n\r", i, j);
printf("=============\n\r");
printf("I= %d , J= %d \n\r", i, j);
printf("-------------\n\r");
printf("I= %d , J= %d \n\r", --i, j--);
printf("-------------\n\r");
printf("I= %d , J= %d \n\r", i, j);
return 0;
}