EmbLogic's Blog

problem in assingment 01

  1. int main()
  2. {
  3.    int x,y,z;
  4.    x=03;y=02;z=01;
  5.    printf(“%d\n”,x|y&z);
  6.   printf(“%d\n”,x|y&~z);
  7.   printf(“%d\n”,x^y&z);
  8.   printf(“%d\n”,x&y&&z);
  9.   x=1;y=-1;
  10.  printf(“%d\n”,!x|x);
  11.   printf(“%d\n”,~x|x);
  12.  printf(“%d\n”,x^x);
  13.  x<<=3; printf(“%d\n”,x);
  14. y<<=3;printf(“%d\n”,y);
  15. y>>=3;printf(“%d\n”,y);
  16. return o;
  17. }

i m facing problem in this program from starting…………how the negiate operator work…………also in left & right shift operator…………

2 Responses to problem in assingment 01

  1. m siddarth says:

    Execution process from top:
    x=03;y=02;z=01;
    printf(“%d\n”,x|y&z);//evaluation is: (x | (y&z))
    printf(“%d\n”,x|y&~z);//evalusation is: (x | (y & (~z)))
    printf(“%d\n”,x^y&z);//evaluation is: (x ^ (y & z))
    printf(“%d\n”,x&y&z);//evaluation is: ((x&y)&z)

    x=1;y=-1;
    printf(“%d\n”,!x|x);//evaluation is: ((!x) | x)
    printf(“%d\n”,~x|x);//evaluation is: ((~x) | x)
    printf(“%d\n”,x^x);// evaluation of XOR operation

    x<<=3; printf("%d\n",x);// initialy x = 01 hence 01<<=3 results to 8
    y<<=3; printf("%d\n",y);// initially y = -01 hence -01 <>=3; printf(“%d\n”,y);// initially y = -08 hence 08 >>= 3 results to -1

  2. hemant.kumar says:

    priority order
    & —> ^ —> |
    if you find ~ ,then solve it first

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>