Boolean's Multiple Questions and Answers.
Exercise Questions ::
C++ Programming
1. Is bool a fundamental data type in C++?
A. No, it is expanded from macros B. No, it is an enum of {false, true} C. No, it is a typedef of unsigned char D. Yes
View Answer
Discuss forum
Workplace
Report
Answer: Option D
Explanation:
C++ has bool as a fundamental data type.
See More Information
Tutorial Link:
Published by:
Answer: Option A
Explanation:
std::vector<bool> is a specialized version of vector, which is used for elements of type bool and optimizes for space. It behaves like the unspecialized version of vector and the storage is not necessarily an array of bool values, but the library implementation may optimize storage so that each value is stored in a single bit.
See More Information
Tutorial Link:
Published by:
Answer: Option C
Explanation:
The given number is a double not an integer, so the function returns 0 which is boolean false.
See More Information
Tutorial Link:
Published by:
4. What happens when a null pointer is converted into bool?
A. The statement is ignored B. Bool value evaluates to false C. Bool value evaluates to true D. An error is flagged
View Answer
Discuss forum
Workplace
Report
Answer: Option B
Explanation:
A pointer can be implicitly converted to a bool. A nonzero pointer converts to true and zero valued pointer converts to false.
See More Information
Tutorial Link:
Published by:
5. For what values of the expression is an if-statement block not executed?
A. 0 B. 0 and -1 C. 0 and all negative values D. 0, all negative values, all positive values except 1
View Answer
Discuss forum
Workplace
Report
Answer: Option A
Explanation:
The if-statement block is only not executed when the expression evaluates to 0. its just syntactic sugar for a branch-if-zero instruction.
See More Information
Tutorial Link:
Published by:
»