Home > C PROGRAMMING > PREDICT THE OUTPUT FOR THE CODE

PREDICT THE OUTPUT FOR THE CODE


void main()
{
int a=1;
printf(“%d%d%d”,a++,++a,a);
}

ur predicted output 1 3 3 is wrong,then…..

OUTPUT:
2 2 1

this is because control in printf statement travels from right to left and not from left to right
hence first ‘a’ is computed then ‘++a’ and then ‘a++’ and printed in the order u have specified
got it..

Categories: C PROGRAMMING Tags:
  1. No comments yet.
  1. No trackbacks yet.

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 )

Connecting to %s

Follow

Get every new post delivered to your Inbox.