Tuesday 10 July 2012

C Language


C Programming Basics



Reserved words - 

                Reserved words are keywords that identify language entities, such as statements, data types etc. and have special meaning to the compiler.

Remark - Must be used in the correct location and must be typed correctly and be used in the right context. 

C language is case sensitive and C keywords must be types fully in lowercase letters. Following are some of the keywords in C -

break, auto, do, char, const, enum, continue, default, if, double, signed, return, for, float, sizeof, int, else, switch, short, void, case, long, unsigned, union, goto, while, volatile, struct and more.

As it can be seen that all the keywords are in lowercase letters. If some uppercase letter appears then it is known as invalid keyword. For Example -  DOUBLE is an invalid keyword whereas double is a valid keyword.




Identifiers -

            Identifiers as the name itself suggests is something that is used to identify a certain entity. In Programming languages identifiers are also known as programmer defined words which are used to identify a variable, function, structure name etc.

There are certain rules that C follows for constructing identifiers such as -

  1. Identifiers can consist of the Capital letters from A to Z, lowercase letters from a to z, the digits 0 to 9 and the underscore character (_).
  2. The first character must a letter or an underscore i.e. an identifier name cannot start from a digit.
  3. There can be no embedded blanks.
  4. Reserved keywords cannot be used as identifiers.
  5. Identifiers are case sensitive i.e. Tax, tax are two different keywords.
For Example - gross_income, _grossincome, gross_income12 are valid identifiers whereas, 1gross_income, gross+income, gross income are invalid identifiers.




No comments:

Post a Comment