Constants:
A
constant specifies a value that appears directly in a program. Its value
doesn’t change during the program execution. Constants are used to create
values that are assigned to variables, used in expressions or passed to
methods.
The constants can be classified as
integer constants, floating- point constants, character constant, string
constants. All these constants are group under primary constants. In addition,
we can also have secondary constants. These include constants for representing
arrays, structures, pointer, union, enum etc.
Example
of integer constants:
10;
013; 772
Example
of character constant:
‘A’;
‘S’; ‘X’;
Example
of String Constant:
“yellow”,”red”.
An
escape sequence is regarded as a single character and is therefore a valid character
constant.
Some
common escape sequence are:
Escape Sequence Character
- \n Newline
- \t Horizontal Tab
- \r Carriage Return
- \a beep
- \xhh Hexadecimal Notation
Post a Comment