Test Series - cpp

Test Number 79/102

Q: Which of the following is correct about any() function in bitset?
A. Returns true if the number of 1’s equal to the number of 0’s
B. Returns true if any bit is set 0
C. Returns true if any bit is set 1
D. Returns true only if all bits are 1
Solution:  header provides the any() function which returns true if any of the bit is set to 1 in the bitset variable.
Q: Which of the following is correct about none() function in bitset?
A. Returns true if any bits is set 1
B. Returns true if all bits is set 0
C. Returns true if the number of 1’s equal to the number of 0’s
D. Returns true only if all bits are 1
Solution:  header provides the any() function which returns true if none of the bit is set to 1 in the bitset variable.
Q: What is the use of the set() function in bitset?
A. Used to make alternate bits zero
B. Used to make a bit 0 in a bitset
C. Used to make all bits zero
D. Used to set bit(s) in a bitset
Solution:  header provides the set() function to set bit(s) to 1 in a bitset variable.
Q: What happens when no argument is supplied to set() function?
A. All alternate bits are set to 1 in a bitset
B. All bits are set to 0 in a bitset
C. All bits are set to 1 in a bitset
D. First bit is set to 1
Solution: When no argument is supplied to set() function i.e. function is called with empty parameters then all the bits of the bitset is set to 1.
Q: What happens when only one argument is supplied to set() function?
A. All bits are set to 1 in a bitset
B. Bit corresponding to an argument is set to 1
C. All alternate bits are set to 1 in a bitset
D. First bit is set to 1
Solution: When only one argument is supplied to set() function then bit corresponding to that index is set to 1.
Q: What is the use of reset function in bitset?
A. Used to make alternate bits zero
B. Used to make a bit 0 in a bitset
C. Used to make all bits 1
D. Used to make a bit(s) 0 in a bitset
Solution:  header provides the reset() function to set bit(s) to 0 in a bitset variable.
Q: What happens when no argument is supplied to reset() function?
A. All bits are set to 1 in a bitset
B. All bits are set to 0 in a bitset
C. All alternate bits are set to 0 in a bitset
D. First bit is set to 0
Solution: When no argument is supplied to reset() function i.e. function is called with empty parameters then all the bits of the bitset is set to 0.
Q: What happens when only one argument is supplied to reset() function?
A. Bit corresponding to an argument is set to 0
B. All bits are set to 0 in a bitset
C. All alternate bits are set to 0 in a bitset
D. First bit is set to 0
Solution: When only one argument is supplied to reset() function then bit corresponding to that index is set to 0.
Q: What is the use of the flip function in bitset?
A. Used to flip bit(s) in a bitset
B. Used to flip a bit in a bitset
C. Used to flip all bits to 1
D. Used to flip alternate bits
Solution:  header provides the flip() function to flip bit(s) in a bitset variable i.e. change the bits in a bitset for example 1100 on flipping becomes 0011.
Q: What happens when no argument is supplied to flip() function?
A. All alternate bits are flipped in a bitset
B. All bits are flipped to 1 in a bitset
C. All bits are flipped in a bitset
D. First bit is flipped
Solution: When no argument is supplied to flip() function i.e. function is called with empty parameters then all the bits of the bitset variable is flipped.

You Have Score    /10