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);
}
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
Excellent use of coding regarding pre-increment and post increment written in C programming. This shows that he is expert in writing coding in c -program. I like this work.
ReplyDeleteNice and helpful for c learners....
ReplyDeleteif-else in C with examples
Strings in C with examples
Switch Case in C examples