
Every literal has a value and a data type. The value of any literal does not change while the program runs and must be in the range of representable values for its type. The following are the available types of literals:
Types:-
- Boolean
- Integer
- Character
- Floating-point
- String
- C Compound literal
- Vector literal
According to Wikipedia a literal is a notation for representing a fixed value in source code. Almost all programming languages have notations for atomic values such as integers,floating-point numbers, and strings, and usually for booleans and characters; some also have notations for elements of enumerated types and compound values such as arrays,records, and objects. An anonymous function is a literal for the function type.
In contrast to literals, variables or constants are symbols that can take on one of a class of fixed values, the constant being constrained not to change. Literals are often used to initialize variables, for example, in the following, 1 is an integer literal and the three letter string in "cat" is a string literal:
0 comments:
Post a Comment