Home / C Programming / Operators and Expressions :: Discussion

Discussion :: Operators and Expressions

  1. What will be the output of the following code fragment?

    void main()

    {

    printf("%x",-1<<4);

    }

  2. A.

     fff0

    B.

     fff1

    C.

     fff2

    D.

     fff3

    E.

     fff4

    View Answer

    Workspace

    Answer : Option A

    Explanation :

    -1 will be represented in binary form as:
    1111 1111 1111 1111

    Now -1<<4 means 1 is Shifted towards left by 4 positions, hence it becomes:
    1111 1111 1111 0000 in hexadecimal form - fff0.


Be The First To Comment