Boolean Literals
The Boolean literals represent the truth values and have only two possible values: true and false. These values are used in the Boolean expressions and logic operations.
Example
C++
// C++ program to illustrate the use of boolean literal #include <iostream> using namespace std; int main() { // using boolean literals bool isTrue = true ; bool isFalse = false ; if (isTrue) { cout << "isTrue is true" << endl; } else { cout << "isTrue is false" << endl; } if (isFalse) { cout << "isFalse is true" << endl; } else { cout << "isFalse is false" << endl; } return 0; } |
Output
isTrue is true isFalse is false
Literals In C++
In C++ programming language, we use literals to represent fixed values. C++ supports various types of literals including integer literals, floating-point literals, character literals, and string literals. In this article, we will discuss all the necessary information on C++ literals and their usage.
Contact Us