Bitwise Operators - Point Out Correct Statements :: Discussion


2.Which of the statements is correct about the program?
A.It counts the number of bits that are ON (1) in the number num.
B.It counts the number of bits that are OFF (0) in the number num.
C.It sets all bits in the number num to 1
D.Error
Answer:  Option  A
Explanation:

If we give input 4, it will print 1.
Binary-4 == 00000000 00000100 ; Total number of bits = 1.

If we give input 3, it will print 2.
Binary-3 == 00000000 00000011 ; Total number of bits = 2.

If we give input 511, it will print 9.
Binary-511 == 00000001 11111111 ; Total number of bits = 9.

Tutorial Link:
Published by:Michael Daani

Comments are not available

Post your comments here:

Optional

Date to Date Current Affairs 2022

PakMCQs.net

Quick Links

GAT Subject



   Computer Science    English Mcqs    Agriculture    

Engineering



   Computer Science    Civil Engineering    

Technical



   Networking    Electronics    Database    

Past Papers



   Model Papers    FPSC Papers