click on this link......

LinkGrand.com

Wednesday 2 January 2013

program to explain the concept of postincrement, postdecrement,predecrement, preincrement operator

#include<stdio.h>
#include<conio.h>
void main()
{
                int a=3;
                printf("Value of a: %d",a);
                printf("Value of post-increment of a: %d",a++);
                printf("Value of a: %d",a);
                printf("Value of pre-increment of a: %d",++a);
                printf("Value of a: %d",a);
                printf("Value of post-decrement of a: %d",a--);
                printf("Value of a: %d",a);
                printf("Value of pre-decrement of a: %d",--a);
                printf("Value of a: %d",a);
                getch();
}

Output:-
 Value of a:3
Value of post-increment of a:  3
Value of a: 4
Value of pre-increment of a: 5
Value of  a: 5
Value of post-decrement of a: 5
Value of  a: 4
Value of pre-decrement of a: 3
Value of  a: 3     

No comments:

Post a Comment