Related Tags

communitycreator
d

# What are boolean literals in D programming?

Chinweuba Elijah Azubuike

### What are literals?

Literals are values of variables that cannot be changed after definition.

### Types of literals in D

There are five types of literals in D programming:

1. Integer numerals
2. Floating-point numerals
3. Characters
4. Strings
5. Boolean values

In this shot, we will focus on the boolean literal.

### What are boolean literals?

Boolean literals convey the boolean logic, which means that there are two boolean literals:

1. True
2. False

True should not be assumed to have the value 1 and false should not be assumed to have the value 0. These boolean literals are the same as the standard D keywords true and false.

### Example

import std.stdio;
bool boolval = true;

int main()
{
writeln(boolval);
return 0;
}
Defining a boolean

### Explanation

Line 2: We define a boolean variable called boolval.

Line 6: Inside the main function, we print the value that boolval contains, which is true.

RELATED TAGS

communitycreator
d

CONTRIBUTOR

Chinweuba Elijah Azubuike
RELATED COURSES

View all Courses

Keep Exploring

Learn in-demand tech skills in half the time