Started with C
Communicating
with a computer involves speaking the language the computer understands.
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.
The C Character Set
A character denotes any alphabet,
digit or special symbol used to
represent information.
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 4 is stored in a memory location and a name x is given
to it. Then we are assigning a new value 6 to the same memory location x.
This would overwrite the earlier value 4, since a 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, 4 or 6 do not
change, hence are known as constants.
Comments
Post a Comment