C Program for pre decrement and post decrement
C Program for understanding the concept of Pre-decrement and Post-decrement
1 2 3 4 5 6 7 8 9 10 11 12 13 |
#include<stdio.h> main() { int i=10,j; j = i--; //j value 10 , i value 11 //post decrement printf("\n After post-decrement: j value: %d , i value:%d \n",j,i); j = --i; //j value 12, i value 12 //pre-decrement printf("\n After pre-decrement: j value: %d, i value:%d \n",j,i); return(0); } |
Output: ( using GNU GCC Compiler with Code Blocks IDE )
After post-decrement: j value: 10 , i value: 9
After pre-decrement: j value: 8, i value: 8
After pre-decrement: j value: 8, i value: 8