C is a general-purpose high-level language that was originally developed by Dennis Ritchie for the Unix operating system. It was first implemented on the Digital Equipment Corporation PDP-11 computer in 1972. The Unix operating system and virtually all Unix applications are written in the C language. This language has now become a widely used professional language for various reasons.

  • Easy to learn
  • Structured language
  • The language produces efficient programs.
  • It can handle low-level activities.
  • This language can compile on a variety of computers.
Facts about C:
  • The language was invented to write an operating system called UNIX.
  • The language was formalized in 1988 by the American National Standard Institue (ANSI).
  • By 1973 UNIX OS was almost totally written in C.
  • Today C is the most widely used System Programming Language.
  • Most of the state of the art software has been implemented using C

Why use C?:

C was initially used for system development work, in particular the programs that make up the operating system. The C programming language was adopted as a system development language because it produces code that runs nearly as fast as code written in assembly language. Some examples of its use might be:

  • Operating Systems
  • Language Compilers
  • Assemblers
  • Text Editors
  • Print Spoolers
  • Network Drivers
  • Modern Programs
  • DataBases
  • Language Interpreters
  • Utilities

HISTORY TO C LANGUAGE:

C is a general-purpose language that has been closely associated with the UNIX operating system for which it was developed. Since the system and most of the programs that run it are written in C. Many of the important ideas of C stem from the language BCPL, developed by Martin Richards. The influence of BCPL on C proceeded indirectly through the language B, which was written by
Ken Thompson in 1970 at Bell Labs, for the first UNIX system on a DEC PDP7. BCPL and B are “typeless” languages whereas C provides a variety of data types. In 1972 Dennis Ritchie at Bell Labs writes the language and in 1978 the publication of The C Programming Language by Kernighan & Ritchie caused a revolution in the computing world. In 1983, the American National Standards Institute (ANSI) established a committee to provide a modern, comprehensive definition of the programing language. The resulting definition, the ANSI standard, or “ANSIC”, was completed in late 1988.

BASIC STRUCTURE OF C PROGRAMMING:

1 Documentation section: The documentation section consists of a set of comment lines giving the name of the program, the author, and other details, which the programmer would like to use later.

2. Link section: The link section provides instructions to the compiler to link functions from the system library such as using the #include directive.

3. Definition section: The definition section defines all symbolic constants such as using the #define directive.

4. Global declaration section: There are some variables that are used in more than one function. Such variables are called global variables. And are declared in the global declaration section that is outside of all the functions. This section also declares all
the user-defined functions.

5. main () function section: Every C program must have one main function section. This section contains two parts; the declaration part and the executable part

6. Declaration part: The declaration part declares all the variables used in the executable part.

7.Executable part: There is at least one statement in the executable part. These two parts must appear between the opening and closing braces. The program execution begins at the opening brace and ends at the closing brace. The closing brace of the main function is the logical end of the program. All statements in the declaration and executable part end with a semicolon.

8. Subprogram section: If the program is a multi-function program then the subprogram section contains all the user-defined functions that are called in the main () function. User-defined functions are generally placed immediately after the main () function, although they may appear in any order

PROCESS OF COMPILING AND RUNNING C PROGRAM:

The C Compilation Model
The Preprocessor
The Preprocessor accepts source code as input and is responsible for
 removing comments
 Interpreting special preprocessor directives denoted by #

For example

 #include — includes contents of a named file. Files are usually called header files.

Ex: #include — standard library maths file, #include — standard library I/O file

 #define — defines a symbolic name or constant. Macro substitution. o #define MAX_ARRAY_SIZE 10

C Compiler
The C compiler translates the source to assembly code. The source code come from the preprocessor

Assembler
The assembler creates object code. On a UNIX system, you may see files with a .o suffix (.OBJ on MSDOS) to indicate object code files.

Link Editor:

If a source file references library functions or functions defined in other source files the link editor combines these functions (with main()) to create an executable file.

Also Read: Flowchart

2 comment on “Introduction to C Programming Language”

Write a comment