A literal number is a number that appears directly in the source code of a program. It is a fixed value that is not calculated or derived from other values. For example, in the expression int x = 5;
, the number 5
is a literal number. It represents the exact value that is assigned to the variable x
.
Literal numbers can be integers, floating-point numbers, or other numeric types depending on the programming language. They are used to specify constant values directly in the code, making it easier to understand and maintain.