EmbLogic's Blog

3rd printf() is printing 4 why????

#include<stdio.h>

int main()

{

int x=2,y,z;

x*=3+2;

printf(“%d\n”,x);

x*=y=z=4;

printf(“%d\n”,x);

x=y==z;

printf(“%d\n”,x);

return 0;

}

3 Responses to 3rd printf() is printing 4 why????

  1. msiddarth says:

    As the statement
    x=y=z; implies that the value in z has to be assign to y and x simultaneously. Hence, the value in x is 4 and correspondingly the printf statement will print 4.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>