EmbLogic's Blog

Problem in assignment 1

Q:-int main()

{ int  x=2,y,z;

x*=y=z=4;

printf(“%d”,x);

x=y==z;

printf(“%d”,x);

x==(y=z)

printf(“%d”,x)

here what is the value of  x in last printf statement?

2 Responses to Problem in assignment 1

  1. himanshi says:

    hyy
    c in the 2nd last expression

    x=y==z
    ie
    y==z ; this is a logical operator itll give ans 1 or 0 acc to the true or false expression

    now
    if y and z are equal then x=1 else 0

    now in last
    x==(y=z)

    in this
    y gets the value eual to z
    then x will be compared with it…..

    ———————————-
    x*=y=z=4
    x=x*4=y=z=4
    as x=2
    new value=>x=8
    y=z=4

    pf=> x=1
    pf=> x=1

    • suresh says:

      In last statement X==(y=z) my answer is 0 but result shown is 1 why?
      updated value of y,z=4 and x=1 in question.

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>