Introduction to C Language

Preview

Introduction to C Language

C Language is a high level programming language developed at “AT & T’s Bell Laboratories”, USA in 1972.

It was written by Dennis Ritchie and Brian Kernighan.

Features of C Language

  • C is a robust language having built-in functions, data types and operators to write complex programs.
  • C Language is a case sensitive language i.e. capital letters and small letters are treated differently.
  • Program written in C language are very efficient and fast. This is due to its variety of data types and powerful operators.
  • It is faster than other programming languages. Hence helps developers in saving their time.
  • It  has the ability to extend itself.
  • It is easy to learn and use C language.



Compilation of C language program

The compilation process of a C program takes place as follows:

  • C program must be saved with extension “.C”. For example, the program is saved with name One.C.
  • After compilation and linking, three more files are generated named as:

One.bak – Back Up file which contains same code of c program.
One.Obj – Object program.
One.exe  -Executable file which can be run directly by the programmer.


Structure of a C Language Program

There are various parts of a C Program They are as follows:

  • Documentation Section
  • Link Section
  • Definition Section
  • Global Declaration Section
  • main() function Section
    • Declaration Part
    • Executable Part
  • Subprogram Section [User Defined Function Section]

1. Documentation Section

This is the very first section of a C Program. In this section, we use comments to specify various aspects related to the program.

2. Link Section

Link section is used to specify the header files to be used in the program and to perform conditional compilation of the program.

3. Definition Section

This section is used to define the macros and symbolic constants to be used in the program.

Examples:

i. #define  PI  3.141

Here, symbolic constant with name PI has been defined which contains value 3.141.

ii. #define cube(x) x*x*x

Here, macro with name cube has been defined. It contains one argument named x. When this macro is invoked, it will return cube of argument passed to it.

4. Global Declaration Section

This section is used to define global variables. The global variables can be used throughout the program. They can be accessed across multiple functions and any changes made to them remain available throughout the program.

5. main() Function Section 

Every program written in C LANGUAGE must have a main() function. The main() function has two sub parts.

(i) Declaration Part

In this part we can declare local variables to be used within function main().

(ii) Executable Part

In this part, we write the statements of C language which are to be executed when we run the program.

6. Subprogram Section

This section contains all the user defined functions designed by the programmer. These functions can be called by the main() function as well as by other functions. These functions can also be defined before main() function.



 

Character Set of C Language

Various characters and symbols which can be used in C language are known as the character set of C Language.

  • Alphabets: a-z,A-Z
  • Digits:- 0-9
  • Special Characters:- #, Colon(:),Semi  Colon (;), Comma(,) etc.
  • White Spaces:- Blank Space, Tab, Backspace, Enter etc.

Token

Token is the smallest identifiable part of a C Program.  Different  types of tokens available in C are.

  • Keyword
  • Identifier
  • Punctuators
  • Variable
  • Constant
  • Operators



Keyword

Keyword is the reserved word provided by C language.  There are basically 32 standard keywords provided by C LANGUAGE.

autoasmbreakcasecharconst
continuedefaultdodoubleelseenum
externfloatforgotoifint
longregisterreturnshortsignedsizeof
staticstructswitchtypedefunionunsigned
voidwhile



Identifier

Identifier refers to those quantities within a program which are defined by a programmer depending upon the requirements.

Rules for naming an identifier are:-

  1. Both digits and alphabets are allowed.
  2. Variable name can contain digits only after first character.
  3. Keyword can’t be used to name a variable.
  4. No special character other than underscore can be used.
  5. It can’t contain spaces.



Punctuators

Various punctuators in C are:

a) Colon (:) It is used with control structures, functions an classes to specify their start

b) Comma (,) It is used to separate variables  during variable definition and expressions.

Best Books of C



Lesson tags: c language introduction, introduction to c, parts of a c program, sections of c program, structure of c program, what is c language
Back to: C Programming Language