PCAP Exam QuestionsBrowse all questions from this exam

PCAP Exam - Question 46


Assuming that the V variable holds an integer value to 2, which of the following operators should be used instead of OPER to make the expression equal to 1?

V OPER 1 -

Show Answer
Correct Answer: C

To make the expression V OPER 1 equal to 1, the proper operator is the right shift operator (>>). The right shift operator (>>) divides the number by 2 for each shift position. Since V is initially 2 (binary 10), performing a right shift by one position (2 >> 1) results in 1 (binary 01). Thus, the correct operator to use is >>.

Discussion

13 comments
Sign in to comment
apextek1Option: C
Mar 16, 2020

answer is C

AmritanshOption: C
Jun 8, 2020

V = 2 V >> 1 print(V) answer is C

john_bosco_championOption: C
Jul 30, 2020

V = 2 # Assigns the value of 2 to variable V print(bin(V)) # Prints the current value of V in binary print(V) # Prints the current value of V in decimal V = V >> 1 # Checking the new value of V after the bitwise right shift of int(2) i.e (from 0b10 to 0b01) print(bin(V)) # Prints the new value of V in binary print(V) # Prints the new value of V in decimal OUTPUT 0b10 2 0b1 1 Hence, the answer is C

guillepowermetalOption: C
Jun 11, 2020

Answer A is not even possible, syntax error

FR99Option: C
Oct 14, 2020

Answer C is the CORRECT one

imsaadOption: C
Jul 24, 2020

Answer A is syntax error, C is the right answer

sacnarOption: C
Aug 8, 2020

answer should be C

imsaadOption: C
Aug 9, 2020

should be C

rbishunOption: C
Oct 29, 2021

print(0b10) # is 2 in decimal print(2 >> 1) # shift 1 bit to the right returns 1 in decimal # Thus C is the correct answer.

rocky48Option: C
Mar 8, 2022

V = 2 V >> 1 print(V)

macxszOption: C
May 3, 2022

answer: C. >>

NetspudOption: C
Feb 14, 2023

It's C

Damon54Option: C
Feb 3, 2024

V = 2 V = V >> 1 print(V)