C Program for understanding the concept of pre-increment and post-increment
PROGRAM:
#include<stdio.h>
main()
{
 int i=10,j;
 j = i++; // j value 10 , i value 11
 //post increment
 printf("\n After post-increment: j value:  %d , i value: %d \n",j,i);
 j = ++i; // j value 12, i value 12
 //pre-increment
 printf("\n After pre-increment: j value: %d, i value : %d \n",j,i);return(0);
}
Output:( using GNU GCC Compiler with Code Blocks IDE )
After post-increment: j value: 10 , i value:11
After pre-increment: j value: 12, i value:12

Leave a Reply

Your email address will not be published.