Communicating with a computer involves speaking the language the computer understands, which immediately excludes English as the language of communication with the computer. However, there is a close similarity between learning English and learning C. The classic method of learning English is to first learn the alphabets used in the language, then to learn how to combine these alphabets to form words, which at in turn they are combined to form sentences and sentences are combined to form paragraphs. Learning C is similar and easier. Instead of immediately learning how to write programs, we need to know first what alphabets, numbers, and special symbols are used in C, then how to construct constants, variables, and keywords, and finally, how to combine them to form a instruction. An instruction group will be combined later to form a program. This is illustrated in Figure 1.1.
The C Character Set
A character indicates any special alphabet, figure or symbol used to represent the information. Figure 1.2 shows the alphabets, numbers and special symbols allowed in C.
Constants, Variables and Keywords
Special alphabets, numbers, and symbols when properly combined constants, variables, and keywords. Let’s see which are “constants” and “variables” in C. A constant is an entity that does not change, while a variable is an entity that can change.
In any program, we usually do a lot of calculations. The results of these calculations are stored in the computer memory. Like human memory, computer memory also consists of millions of cells. The calculated values are stored in these memory cells. To facilitate the retrieval and use of these values, these memory cells (also called memory locations) are given names. Because the value stored in each location can change the name given to these locations, variable names are called. Consider the following example.
Here 3 is stored in a memory location and is given an x name. Then we assign a new value 5 to the same memory location x. This would overwrite the previous value 3, because a memory location can hold only one value at a time. This is shown in Figure 1.3.
Because the location whose name is x can hold different values at different times x is known as a variable. Against this, 3 or 5 does not change, which is why they are known as constants