Q: What is bitset in C++?
Solution: Bitset is a collection of bool variables with each element consuming only one bit. They are introduced for efficient use of memories.
Q: Which of the following is correct about bitset and vector of bools?
Solution: Bitset consumes less space compared to bool vector however the size for bitset is static whereas for bool vector size is dynamic.
Q: Which of the following is the limitation of bitset over vector bool?
Solution: Bitset size is static whereas vector size is dynamic therefore the size of a vector can be increased or decreased which is not possible in bitset.
Q: Which operator is used to access the nth bit in a bitset?
Solution: [] operator is used to access the nth bit of a bitset from the right side. For example, if my bitset b is 1010 then b[0] represents 0 and b[1] represents 1.
Q: How many ways are there for constructing a bitset?
Solution: There are three ways of constructing a bitset. Direct construction, using integer number and using binary string.
Q: Which is the correct syntax of constructing a bitset?
Solution: All of the above mentioned are correct syntax of constructing a bitset. However each has different way of interpretation.
Q: Which of the following is corect way of constructing bitset using integer number?
Solution: The correct way of constructing bitset using integer number is as follows: bitsetb(integer_number);
Q: Which of the following is corect way of constructing bitset using binary string?
Solution: The correct way of constructing bitset using binary string is as follows: bitsetb(string(“1100”));
Q: What is the default value of a bitset?
Solution: By default, all the bits of a bitset variable is set to 0 i.e. the value of bitset variable is 0.
Q: Which header file is required for using bitset in your program?
Solution:header file is required to use the functionality of bitsets in your program i.e. use of binary string in your program.
You Have Score    | /10 |