Exam PCAP All QuestionsBrowse all questions from this exam
Question 2

And operator able to perform bitwise shifts is coded as (Choose two.)

    Correct Answer: C, D

    The bitwise shift operators are '<<' for left shift and '>>' for right shift. The '<<' operator shifts the bits of a number to the left, effectively multiplying the number by 2 for each shift position. The '>>' operator shifts the bits to the right, effectively dividing the number by 2 for each shift position. Both '++' and '--' are not bitwise operators; they are unary operators used for incrementing and decrementing values, respectively.

Discussion
zaxxyOptions: CD

C. << D. >>

BereOptions: CD

x = 8 # 8 in Binary: 1000 y = x >> 2 # Right shift by 2 positions: 0010 (in binary) which is 2 in decimal print(y) # Output: 2 x = 4 # 4 in Binary: 0100 y = x << 2 # Left shift by 2 positions: 10000 (in binary) which is 16 in decimal print(y) # Output: 16

saturn_samOptions: CD

C and D

mplopezOptions: CD

The answers are C and D.

DrMKGOptions: CD

Answer is C,D

DinshaOptions: CD

C. << d. >>

macxszOptions: CD

C. << D. >>

chafikislamOptions: CD

>> right shift between integer value (division by 2) <<left shift (multiplication by 2)

AndresfvOptions: CD

>>Desplazamiento a la derecha bit a bit << Desplazamiento a la izquierda bit a bit