What is The C Language character Set & about Constants ,Variables and keywords ?
The C Language character Set
A Character denotes any alphabet ,digit or special symbol used to represent information . Figure 2 shows the valid alphabets numbers and special symbols allowed in c.
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’s memory. Like human memory, the computer’s 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 locations are called variable names. Consider the example shows m Figure 1.3.
Here 3 is stored in a memory location and a name x is given to tt Then we have assigned a new Value 5 to the same memory location x. This would overwrite the earlier value 3, since ® memory location can hold only one value at a time.
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 not change , hence are known as constants
Type of constants
C constants can be divided into two major categories:
1. primary Constants
2. secondaty canstant
these constants are further categorized as show in the figure 4.
Papa, [28.05.21 21:17]
At this stage, we would restrict our discussion to only Primary constants, namely, Integer, Real and Character constants. 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:
ad
Rules for Constructing Integer Constants
(a) An integer constant must have at least one digit.
(b) It must not have a decimal point.
(c) It can be either positive or negative.
(d) If no sign precedes an integer constant, it is assumed to be positive.
(e) Nocommas or blanks are allowed within an integer constant.
(f) 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
Papa, [28.05.21 21:18]
range is -32768 to 32767 For a 32 bit compiler, the range would be even greater Questions like what exactly do you mean by a {6
bit or a 32 bit compiler, What range of an Integer constant has to do with the type of compiler, ete are dincunsed in detail in Chapter 16 Till that time it would be asaumed that we are working with a 16-bit conpiler
Ex 486 +782 8000 1c 8s)
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.
Following rules must be observed while constructing real » constants expressed in fractional form: . (a) Areal constant must have at least one digit. (b) It must have a decimal point. (c) It could be either positive or negative. (d) Default sign is positive. (e) 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 exponential form of representation for other real constants.
Comments
Post a Comment