Indentifiers, Keywords, Constants
Indentifiers, Keywords, Constants
Date:19.09.23
THE C CHARACTER SET
• C uses the uppercase letters A to Z, the lowercase letters a to z, the digits 0 to 9, and certain special
characters as building blocks to form basic program elements (e.g., constants, variables, operators,
expressions, etc.).
• The special characters are listed below.
• Most versions of the language also allow certain other characters, such as @ and $, to be included
within strings and comments.
• C uses certain combinations of these characters, such as \b, \n and \t,to represent special conditions
such as backspace, newline and horizontal tab, respectively. These character combinations are
known as escape sequences.
IDENTIFIERS AND KEYWORDS
• Identifiers are names that are given to various program elements, such as variables, functions and arrays.
• Identifiers consist of letters and digits, in any order, except that the first character must be a letter.
• Both upper- and lowercase letters are permitted, though common usage favors the use of lowercase letters for most types of
identifiers.
• Upper- and lowercase letters are not interchangeable (i.e., an uppercase letter is not equivalent to the corresponding lowercase
letter.)
• The underscore character (_) can also be included and is considered to be a letter.
• An underscore is often used in the middle of an identifier. An identifier may also begin with an underscore.
• Example:
• Valid Identifiers:
X Y12 sum_1 _temperature
• Invalid Identifiers:
4th The first character must be a letter.
"x" Illegal characters (“).
order-no Illegal character (-).
error flag Illegal character (blank space).
IDENTIFIERS AND KEYWORDS
• An identifier can be arbitrarily long. Some implementations of C recognize only
the first eight characters, though most implementations recognize more (typically,
31 characters).
• Example: The identifiers file-manager and file-management
• As a rule, an identifier should contain enough characters so that its meaning is
readily apparent. On the other hand, an excessive number of characters should be
avoided.
• There are certain reserved words, called keywords, that have standard, predefined
meanings in C.
• These keywords can be used only for their intended purpose; they cannot be used
as programmer-defined identifiers.
IDENTIFIERS AND KEYWORDS
• The standard keywords are
• Some compilers may also include some or all of the following keywords.
Bit,Byte,Nibble,word
1.Bit (Binary Digit):
•A bit is the smallest unit of data in computing and digital communications.
•It can have a value of either 0 or 1, representing off or on, respectively.
•The term "bit" is a contraction of "binary digit."
2.Byte:
•A byte consists of 8 bits.
•It is a fundamental unit of data storage and processing in computing.
•Bytes are used to represent characters (e.g., letters, numbers, symbols) and are the basis for addressing and storing data in memory.
3.Nibble:
•A nibble is half of a byte, containing 4 bits.
•Nibbles are used in computing operations where it's useful to work with small units of data.
4.Word:
•The size of a word can vary depending on the computer architecture and the specific system, but it's typically the natural unit of data a
CPU can process at one time (e.g., 16 bits, 32 bits, 64 bits).
•A word's size is an essential characteristic of a computer's architecture, affecting memory addressing and processing capabilities.
• The maximum permissible values of unsigned and long integer constants will vary from one computer (and
one compiler) to another. With some computers, the maximum permissible value of a long integer constant
may be the same as that for an ordinary integer constant; other computers may allow a long integer constant
to be much larger than an ordinary integer constant.
• Note:
• Suppose a particular computer uses a w-bit word. Then an ordinary integer quantity may fall within the range -2w – 1
to +2w - 1, whereas an unsigned integer quantity may vary from 0 to 2w - 1. A short integer may substitute w/2 for w,
and a long integer may substitute 2w for w. These rules may vary from one computer to another.
CONSTANTS
• Floating-Point Constants
• is a base- 10 number that contains either a decimal point or an exponent (or
both).
• Example: Valid Floating-Point Constants