Hello friends, today we are going to see what is 'C' constants, variables and keywords? how to use that and why to use?
|
'C' Constants, variables and keywords |
Definition
When the alphabets, numbers and special symbols properly combined form constants, variables and keywords. The detail definition is as follows.
Constants:
A constant is a quantity that doesn’t change. This quantity can be stored at fix memory location and whenever needed computer can show the same value. Examples: 5, 7, 12.6, 1050 etc.
Constants can be divided into two major categories and some sub categories, these are as follows:
Primary Constants and Secondary Constants.
|
Secondary Constants
|
Integer Constants
|
Array
|
Real Constants
|
Pointer
|
Character Constants
|
Structure
|
|
Union
|
|
Enumerated
|
Primary Constants:
Integer Constants:
Rules
- An integer constant must have at least one digit.
- It doesn’t have a decimal point.
- It could be either positive or negative, default sign is positive.
- No commas or blanks are allowed within an integer.
- The range of integer constants is -32768 to +32767
Example: 426, +782, -7654 etc.
Real Constants:
Real constants are also called Floating point constants. This constants could be written in two forms. Fractional form and Exponential form.
Rules
- A real constant must have at least one digit.
- It must have a decimal point.
- It could be either positive or negative, default sign is positive.
- No commas or blanks are allowed within a real constants
- In exponential form, the mantissa part (the part appearing before ‘e’ is called mantissa) and the exponential part (the part following ‘e’) should be separated by a letter e.
- The range of real constants is -3.4e38 to 3.4e38
- Example: +325.34, 426.0, -32.76, 6.8e-5, -0.4e8, -4.9e-3 etc.
Character Constants:
The Character constants can be used to store a single character such as a single alphabet or letter ’a’ the single digit ’6’ or a single special symbol enclosed within single inverted commas.
Rules
- Both the inverted commas should point to the left.
- The maximum length of a character constant can be 1 character.
- Example: ’A ’, ’$’, ’5 ’, ’=’ etc.
Variables
A variable is a location where the constant is stored. The contents of the variable can be changed.
Example: 3X+Y=20
Here X and Y are the variables and 20 and 3 are the constants.
Rules
- A variable name is any combination of 1 to 8 alphabets, digits or underscores.
- The first character must be an alphabet.
- No commas or blanks are allowed within a variable name.
- Only underscore are valid as a special symbol.
Example: si_int, m_hra, pop_e_89 etc.
Keywords
Keywords are the words whose meaning has already been explained to the computer. The keywords cannot be used as variable names. The keywords are also called as ‘Reserved words’. Example: break, for, int, float, void etc.
Well, did you like this post, please give me your valuable reviews as comment. It will help me to improve my self.
this is nice blog with brief information
ReplyDelete