Which data type would be most appropriate for storing a boolean value?
- int
- char
- double
- bool
The bool data type is specifically designed in C++ to store boolean values, which can be either true or false. Using other data types like int, char, or double for boolean values would be inefficient and not semantically clear. Thus, bool is the most appropriate choice for this purpose.
Loading...
Related Quiz
- Which function is used to get the position of the file pointer in a file?
- When passing parameters by reference, which symbol is used to denote reference in C++?
- To prevent a class from being inherited, we declare it as _______.
- What is the use of a catch block with an ellipsis (...)?
- In C++, if a programmer forgets to deallocate memory using delete, it can result in a _______.