Header Ads

Constants in C

What is constants in C?

C constants can be divided in two major categories:
1.       Primary constants
2.       Secondary constants
Primary Constants: - Integer constant, real constant (Float constant) and character constant


Secondary constants: - Array, Pointer, Structure, Union, Enum. Etc.

Primary Constants:

Rules for constructing integer constants: -

a.       An integer constant must have at least one digit.
b.      It must not have a decimal point.
c.       It can be either positive or negative.
d.      Default sign is positive.
e.      No commas or blanks are allowed within an integer constant.
f.        Range of constants are +2147483648 to-2147483647.

Rules for constructing real constants: -

a.      A real constant must have at least one digit.
b.      It must have a decimal point.
c.       It could be either positive or negative.
d.      Default sign is positive.
e.      No commas or blanks are allowed within a real constants.

Rules for constructing character constants: -

a.      A character constant is a single alphabet a single digit or a single symbol enclosed within single inverted commas. i.e. ’A’  ’I’  ’=’

b.      Both the inverted commas are should point to the left. For example, ’A’ is a valid whereas ‘A’ is not valid.

No comments