A
constant is defined as follows:
#define SYMBOLIC_NAME value_of_constant
e.g.
#define PASS_MARK 50
#define MAX 100
#define PI 3.14159
Symbolic
names are sometimes called constant identifiers.
The
following rules apply to a #define statement:
1) Symbolic
names have the same form as variable names. (Symbolic names are written in
CAPITALS to visually distinguish them from the normal variable names, which are
written in lowercase letters. This is only a convention, not a rule.)
2)
No blank spaces between the pound sign
‘#’ and the word ‘define’ is permitted.
3)
‘#’ must be the first character in the
line.
4)
A blank space is required between
#define and symbolic name and between symbolic name and the constant.
5)
#define statements must not end with a
semicolon.
6)
After definition, the symbolic name
should not be assigned any other value within the program by using an
assignment statement. e.g. MAX = 500; is illegal.
7) Symbolic
names are NOT declared doe data types. Its data type depends on the type of
constant.
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.