This website completely moved to new platform. For latest content, visit www.programmingposts.com

Search this Site

22 Jul 2012

C Program for pre decrement and post decrement

c program for understanding the concept of pre decrement and post decrement

#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

No comments:

Post a Comment

Thanks for your comments.
-Sameer