Communicating with a computer involves speaking the language
the computer understands, which immediately rules out English as the language of
communication with computer. However, there is a close analogy between learning
English language and learning C language. The classical method of learning
English is to first learn the alphabets used in the language, then learn to
combine these alphabets to form words, which in turn are combined to form
sentences and sentences are combined to form paragraphs. Learning C is similar
and easier. Instead of straight-away learning how to write programs, we must
first know what alphabets, numbers and special symbols are used in C, then how
using them constants, variables and keywords are constructed, and finally how
are these combined to form an instruction. A group of instructions would be
combined later on to form a program. This is illustrated in the Figure 1.1.
A character denotes any alphabet, digit or special symbol used
to represent information. Figure 1.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 computers memory.
Like human memory the 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 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 3, since a memory location can hold only one value at a time. This
is shown in Figure 1.3.
Next topic : Let us C chapter 1 GETTING STARTED (part 3)
Previous topic : Let us C chapter 1 GETTING STARTED (part 1)
Full book : All Topics
Please, don’t forget to subscribe to our fantastic RSS feed free newsletter, join Dbstudies community on Facebook! If you enjoyed our posts we humbly ask you to comment, and help us spread the word!
0 Comments:
Post a Comment