TechnologY

The Game Of Incrementation

Output with EXPLANATION…

void main() {
int j = 10;
printf(“%d****%d*****%d\n”, j,++j,j++);

j = 10;
printf(“%d****%d*****%d\n”, j++,j,j++);
j = 10;
printf(“%d****%d*****%d\n”, ++j,j++,j);
printf(“change\n”);

j = 10;
printf(“%d****%d*****%d\n”, j,j++,++j);
j = 10;
printf(“%d****%d*****%d\n”, ++j,j,j++);
j = 10;
printf(“%d****%d*****%d\n”, j++,++j,j);
getch();
}
OUTPUT in VS2010 in Windows7 and gcc in Ubuntu…
12****12*****10
11****12*****10
12****10*****12
change
12****11*****12
12****12*****10
11****12*****12

Because the precedence order postorder>preorder>local variable>printf
1. the Stack is filled in the above order as the local variable always first Stack-up
2. stack is one of data structures used to store data where in this the first data to be stored is the last element to be retrieved
3. printf command starts storing elements in Stack from left to right
4. store from left to right, then poped and evaluated right to left then print from left to write according to specified order..((this logic does not apply though))

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s