A character denotes any alphabet, digit, or special symbol used to represent information. below given data shows the valid alphabets, numbers, and special symbols allowed in C.

• Alphabets - A, B, ......., Y, Z or a, b, ......., y, z
• Digits    - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
• Special symbols ~ ' ! @ # % ^ & * () _ - + = | / {} [] : ; " <> , . ?

## Constants, Variables, and Keywords

The alphabets, numbers, and special symbols when properly combined form constants, variables, and keywords Let us see what are constants ' and ' variables ' in C. A constant is an entity that doesn't change whereas a variable is an entity that may change.

In any program, we typically do lots of calculations The results of these calculations are stored in computer memory Like human memory computer memory also consists of millions of cells The calculated values are stored in these memory cells. To make the retrieval and usage of these values easy these memory cells ( also called memory locations ) are given names Since the value stored in each location may change the names given to these example locations are called variable names. Consider the following example.

Here 3 is stored in a memory location and a name x is given to it Then we are assigning a new value 5 to the same memory location x. This would overwrite the earlier value of 3 since a memory location can hold only one value at a time. This is shown in the below-given image.

Since the location whose name is x can hold different values at different times x is known as a variable As against this, 3 or 5 do change, hence are known as constants.

### Types of C Constants

C constants can be divided into two major categories

1. Primary Constants
2. Secondary Constants

These constants are further categorized as shown in the below-given image.

Let us see the details of each of these constants. For constructing these different types of constants certain rules have been laid down These rules are as under

#### Rules for Constructing Integer Constants

1. An integer constant must have at least one digit.
2. It must not have a decimal point.
3. It can be either positive or negative.
4. If no sign precedes an integer constant it is assumed to be positive.
5.  No commas or blanks are allowed within an integer constant.
6. The allowable range for integer constants is -32768 to 32767.

Truly speaking the range of an Integer constant depends upon the compiler For a 16 - bit compiler like Turbo C or Turbo C ++ the range is -32768 to 32767 For a 32 - bit compiler the range would be even greater. let’s say we are working with a 16 - bit compiler.

Ex . 426

+782

- 8000

-7605

#### Rules for Constructing Real Constants

Real Constants are often called Floating Point constants. The real constants could be written in two forms - Fractional form and Exponential form.

The following rules must be observed while constructing real constants expressed in the fractional form.

1.  A real constant must have at least one digit.
2. It must have a decimal point.
3. It could be either positive or negative.
4. The default sign is positive.
5. No commas or blanks are allowed within a real constant.

Ex +325.34

426.0

-32.76

-48.5792

The exponential form of representation of real constants is usually used if the value of the constant is either too small or too large. It however doesn't restrict us in any way from using an exponential form of representation for other real constants.

In the exponential form of representation, the real constant is represented in two parts. The part appearing before e ' is called mantissa, whereas the part following ' e ' is called the exponent.

Following rules must be observed while constructing real constants expressed in exponential form:

1. The mantissa part and the exponential part should be separated by the letter e.
2. The mantissa part may have a positive or negative sign.
3. The default sign of the mantissa part is positive.
4. The exponent must have at least one digit, which must be a positive or negative integer. The default sign is positive.
5. The range of real constants expressed in exponential form is -3 4638 to 3,4038.

Ex: +3.2e-5

4.108

-0.2e+3

-3.2e-5

#### Rules for Constructing Character Constants

1. A character constant is a single alphabet, a single digit, or a single special symbol enclosed within single inverted commas. Both the inverted commas should point to the left. For example, ’A’ is a valid character constant whereas ‘A’ is not.
2. The maximum length of a character constant can be 1 character.

Ex. ’A’

’I’

’5’

’=’

### Types of C Variables

As we saw earlier, an entity that may vary during program execution is called a variable Variable names are names given to locations in memory These locations can contain an integer, real, or character constants. In any language, the types of variables that it can support depend on the types of constants that it can handle This is because a particular type of variable can hold only the same type of constant For example, an integer variable can hold only an integer constant, a real variable can hold only a real constant and a character variable can hold only a character constant.

The rules for constructing different types of constants are different, However, for constructing variable names of all types the same set of rules applies. These rules are given below.

#### Rules for Constructing Variable Names

1. A variable name is any combination of 1 to 31 alphabets, digits, or underscores. Some compilers allow variable names whose length could be up to 247 characters. Still, it would be safer to stick to the rule of 31 characters. Do not create unnecessarily long variable names as it adds to your typing effort.
2. The first character in the variable name must be an alphabet or underscore.
3. No commas or blanks are allowed within a variable name.
4. No special symbol other than an underscore ( as in gross_sal ) can be used in a variable name.
These rules remain the same for all the types of primary and secondary variables Naturally, the question follows. how is C able to differentiate between these variables? This is a rather simple matter.

The c compiler is able to distinguish between the variable names by making it compulsory for you to declare the type of any variable name that you wish to use in a program This type declaration is made at the beginning of the program Following are examples of type declaration statements.

Ex int si, m_hra;

float bassal;

char code;

Since the maximum allowable length of a variable name is 31 characters, an enormous number of variable names can be constructed using the above-mentioned rules. It is a good practice to exploit this enormous choice in naming variables by using meaningful variable names. Thus, if we want to calculate simple interest, it is always advisable to construct meaningful variable names like prin, roi, noy to represent Principle, Rate of interest, and Number of years rather than using the variables a, b, c.

## C Keywords

Keywords are words whose meaning has already been explained to the C compiler ( or in a broad sense to the computer ). The keywords cannot be used as variable names because if we do so we are trying to assign a new meaning to the keyword, which is not allowed by the computer Some C compilers allow you to construct variable names that exactly resemble the keywords. However, it would be safer not to mix up the variable names and the keywords. The keywords are also called ' Reserved words ' There are only 32 keywords available in C. below-given image shows a list of these keywords for your ready reference A detailed discussion of each of these keywords would be taken up in later chapters wherever their use is relevant.

1. auto
2. break
3. case
4. char
5. const
6. continue
7. default
8. do
9. double
10. else
11. enum
12. extern
13. float
14. for
15. goto
16. if
17. int
18. long
19. register
20. return
21. short
22. signed
23. sizeof
24. static
25. struct
26. switch
27. typedef
28. union
29. unsigned
30. void
31. volatile
32. while

Note that compiler vendors ( like Microsoft, Borland, etc. ) provide their own keywords apart from the ones mentioned above. These include extended keywords like near, far, asm, etc. Though it has been suggested by the ANSI committee that every such compiler-specific keyword should be preceded by two underscores ( as in asm ), not every vendor follows this rule.