As we know the basic way
of learning the English:
Alphabets → Words → Sentences → Paragraph
Similarly, In a
programming language:
Alphabets,
Digits, Special Symbols: Set called as Character Set
↓
Constants,
Variables, Keywords
↓
Instructions
↓
Program
The Character Set
A character denotes any
alphabet, digit, or special symbol used to represent information.
Alphabets: a, b, c, ....
y, z, and A, B, C, …. Y, Z.
Digits: 0, 1, 2, 3, 4, 5,
6, 7, 8, 9.
Special Symbols: ~ ` ! @
# $ % ^ & * ( ) _- = + ………….
After the combination
form of characters make Constants, Variables, and Keywords.
Constant:
A constant is an entity that doesn’t change.
Variable:
A variable is an entity that may change.
Keyword:
A keyword is a word that carries special meaning.
Types of Constants
1.
Primary Constants
a. Integer
Constant
b. Real
Constant
c. Character
Constant
2.
Secondary Constants
a. Array
b. Pointer
c. Structure
d. Etc…
Rules of Constructing
Integer Constants
- It must have at least one digit.
- It must not have a decimal point.
- It can be any of zero, positive or
negative.
- Default sign is positive.
- No commas or blanks are allowed within an
integer constant.
- The allowable range from (-2147483648) to
(+2147483647).
Example:
426
+782
-8000
-7502
Rules of Constructing Real
Constants/ Floating Point Constants
- It must have at least one digit.
- It must have a decimal point.
- It can be any of zero, positive or
negative.
- Default sign is positive.
- No commas or blanks are allowed within an
integer constant.
Example:
562.30
+571.2
-85.10
-75.02004
Note:
When the value of real constants is either too small or too large so this used
in the exponential form of real constants.
Exponential
form divided into the two parts:
The
part appearing before ‘e’ is called mantissa, whereas the part following ‘e’ is
called exponent.
Rules of Constructing Exponential
Real Constants.
- The mantissa part and exponential part should be separated by a letter e or E.
- The mantissa part may have a positive or a
negative.
- Default sign of mantissa part is positive.
- The exponent must have at least one digit,
which must be a positive or negative integer. Default sign is positive.
- The allowable range from (-3.4e38) to
(+3.4e38).
Example:
562e30
+571E2
-85e10
Rules of Constructing Character
Constants.
1.
A character constant is a single alphabet,
a single digit, or a single special symbol enclosed within single inverted
commas.
Example:
′A′
′d′
′5′
′=′
Rules
of Constructing Variable.
- A particular variable can hold only the same type of constant.
- But in the variable name we can use combination of alphabets, digits, and underscore (not use any other special symbol).
- Always start the variable name use of alphabets and underscore. Not use the digits in the starting of variable name that is invalid.
Example:
abc_
ab123
kfh
_fj
_5142
Keywords
In the different
programming language have different keywords which used. But their meaning has already
been explained to the compilers.
Here I write the common keywords:
- break
- double
- int
- long
- else
- for
- char
- const
- default
- do
- float
- switch
- etc…