Start Learning:
As a matter of fact any language whether it is natural
language (like Hindi, English, French, etc) or computer programming language,
one has to learn basic constituents first.
For example alphabets are basic constituents of English
language.
In a similar fashion we have to learn basic constituents of
C language.
The order of our journey contains:
Basic letters à
Identifiers à
Instructions à Program
Basic Letters:
Language writing includes letters as:
Alphabets: a to z and A to Z
Digits:
0 to 9
Special Symbols: +,%,*, &, “, >, ?, \, :, ;, -, ^
,{, [, ), etc
Identifiers:
Identifiers are smallest unit in the program that has some
meaning. We know that compiler will be reading our source code to translate it
in object code. So compiler should know about all the words of our program. Few
words are predefined to compiler and rest need to be declared by the
programmer. These words are identifiers as they can be identified by compiler.
Identifier includes constants, variables, keywords, macros,
function name etc.
Here we are going to understand three of these; they are
constants, variables and keywords.
Constant:
Software is developed to handle information. This
information is called constant. Sometimes it is termed as data.
Constants can be categorized as Primary and secondary
constants
Primary constants:
Primary constants are
also known as fundamental constants or basic constants. They are of three
types; Integer constant, Real constant, Character constant.
All numbers without
decimal point involved in it are integer constants.
For example: 35, -20, 0, 123 etc
All numbers with
decimal point involved in it are real constant.
For example: 3.14, -43.56, 3.0 etc
All character
symbols are character constants if they are enclosed in single quotes and of
unit length.
For example: ‘A’, ‘b’, ‘+’, ‘3’, ‘ ‘
Secondary constants:
Secondary constants are also known as derived constants, as
they are derived from primary constants.
Arrays, strings, pointers, structures, union, enumerators
are secondary constants.
We will see them in great detail in later chapters.
Variables:
Variables are the name of memory locations where we store
our data. When C program is under execution, operating system allocates memory
to store instructions of the program and also allocates space to store data.
Programmer has to decide how much space he is required with
to store data. He also specifies the names of memory blocks in his program
code. These names are called variables.
We can change its value according to programming
requirement.
Variable name may contain alphabets, digits or underscore.
No other symbol is allowed.
A valid variable name never starts with digit.
Keywords:
Keywords are predefined words. They are also known as
reserved words. Their meaning is known to the compiler.
ANSI (American National Standards Institute) announces 32
keywords in C language, but it may vary with compilers.
Keywords are predefined and we will see their meaning in
subsequent chapters.
Here is the list of keywords:
auto break case char
continue const do default
double else enum extern
for float
far
goto
huge int if long
near return
register
short
static struct signed union
unsigned void
volatile while
These keywords can not be used as variable or function names
as they already have some meaning known to compiler.
No comments:
Post a Comment