Start Learning C

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.
You have to learn C language in the same fashion as you have learnt English language, that is start with the alphabets, proceed with words and then combine words to form a meaningful statements.






Here, you can split your journey of learning C language in the following four steps:

  • Basic Letters
  • Identifiers
  • Instructions
  • Program

Basic Letters

Alphabets A to Za to z
Digits 0 to 9
Special Symbol example: ~ ‘ ! @ # % ^ & * ( ) _ – + = | \ { } [ ] : ; “ ‘ < > , . ? /

Identifier
Combination of letters becomes an identifier. Identifier is the smallest unit in the program which has some meaning. You are going to learn following identifiers in this chapter:

  • Constant
  • Variables
  • Keywords

Constant
Any Software is developed to handle information. This information is called constant. Sometimes it is termed as data (raw or processed).
data = information = constant

Constants can be categorized as primary and secondary constants.

Primary Constant
Primary constants are also known as fundamental constants or basic constants. They are of three types:

  • Integer constant
  • Real constant
  • Character constant

Integer Constant
All numbers either positive or negative without decimal point are Integer Constant

For example: 35, -20, 0, 123 are valid Integer constant

If the sequence of digits is preceded by 0x or 0X (zero x or zero X), then the constant is considered to be hexadecimal (base 16). Hexadecimal values may use the digits from 0 to 9, as well as the letters a to f and A to F. Few examples: 0x2f, 0X3a2, 0xAB2,
If the first digit is 0 (zero), and the next character is not ‘x’ or ‘X’, then the constant is considered to be octal (base 8). Octal values may only use the digits from 0 to 7; 8 and 9 are not allowed. For example: 052, 037

Real Constant
All numbers either positive or negative with decimal point involved in it are real constant.
For example: 3.14, -43.56, 3.0 are valid Real constant.

Real constants are also known as floating point literals. A floating-point literal has an integer part, a decimal point, a fractional part, and an exponent part. You can represent floating point literals either in decimal form or exponential form.

While representing decimal form, you must include the decimal point, the exponent, or both; and while representing exponential form, you must include the integer part, the fractional part, or both. The signed exponent is introduced by e or E.

More examples: 3.14e5, 0.34e-4

Character Constant
All character symbols are character constants if they are enclosed in single quotes and of unit length.
For example: ‘A’, ‘b’, ‘+’, ‘3’, ‘ ‘
There are few special characters whose length is two characters but they are treated as single character, like ‘\n’, ‘\t’, etc.

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 names 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 is required to store data. He also specifies the names of memory locations in his program code. These names are called variables. These locations can contain integer, real and character constants.
We can change its value according to programming requirement.
Rules for constructing variable name:

  • Variable name may contain alphabets, digits or underscore.
  • No other symbol or blank 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 const continue default do
default else enum extern float for goto if
int long register return short signed sizeof static
struct switch typedef union unsigned void volatile while

ISO C99 adds the following keywords:
inline _Bool _Complex _Imaginary
These keywords cannot be used as variable names or function names as they already have some meaning known to compiler.

Start Learning C