EmbLogic's Blog

Hi! i have problem with these expressions:-

y=z=4;

x=y==z; printf(“%d,”x);

x==(y=z);printf(“%d”,x);

what is  value of x in these two printf statement?

6 Responses to

  1. as y==z returns true value i.e 1 ,therefore this value is assigned to x ,hence x=1 in first expression,…
    and in second one, value of z i.e 4 is assigned to y & x==4 returns false value therefore x returns previous value stored in it i.e 1……

  2. y==z returns 1 which is assigned to x therefore
    x=1
    x==(y=z) does no effect on value of x

  3. In second statement, value of z i.e 4 is assigned to y & x==4 returns false value & then x returns previous value stored in it,
    This is due to exception handling & throw function in this compiler which prints previous stored value.
    u can check it by removing statement x=y==z and then executing program.

Leave a Reply to simarpreet.singh Cancel 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>