Chapter 5 - Introduction To C Programming Language
Chapter 5 - Introduction To C Programming Language
Chapter Objectives
By the end of this chapter the learner should be able to;
Describe the characteristics of C programming language.
Describe the process of developing and Executing a C program
Describe the compilation process of a C program and C program file naming conventions.
Differentiate between Syntax and Logical Errors
Describe the structure / format of a C Program
5.1. Introduction
C is an imperative (procedural) systems implementation language. C is one of a large number of
high level languages which can be used for general purpose programming, that is, anything from
writing small programs for personal amusement to writing complex applications. C is a general-
purpose computer programming language developed between 1969 and 1973 by Dennis Ritchie
at Bell telephone Laboratories.
5.2. Characteristics of C
We briefly list some of C's characteristics that define the language and also have lead to its popularity as
a programming language.
Small size
Extensive use of function calls
Loose typing
Structured language
Low level (BitWise) programming readily available
Pointer implementation - extensive use of pointers for memory, array, structures and functions.
Features
1) C library, a library is a set of functions
2) C allows meaningful variable names and meaningful function names to be used in programs
without any loss of efficiency and it gives a complete freedom of style;
3) it has a set of very flexible loop constructions (for, while, do) and neat ways of making
decisions.
4) C tries to make the best of a computer by linking as closely as possible to the local
environment.
Disadvantages
Its main drawback is that it has poor error detection which can make it off putting to the
beginner. However diligence in this matter can pay off handsomely since having learned the
rules of C we can break them. Not many languages allow this. This if done properly and
carefully leads to the power of C programming.
During the stages of compilation, linking, and running, error messages may occur that require
the programmer to make corrections to the program source (debugging). The cycle of modifying
the source code, compiling, linking, and running continues until the program is complete and
free of errors.
5.8. C Libraries
In C, a library is a set of functions contained within a single "archive" file. The core of the C
language is small and simple. Special functionality is provided in the form of libraries of ready-
made functions. This is what makes C so portable. Libraries are files of ready-compiled code
which we can merge with a C program at compilation time. Libraries provide frequently used
functionality and, in practice, at least one library must be included in every program: the so-
called C library, of standard functions.
Each library comes with a number of associated header files which make the functions easier to
use. Header files contains the prototypes of the functions contained within the library that may
be used by a program, and declarations of special data types and macro symbols used with these
functions. It is up to every programmer to make sure that libraries are added at compilation time
by typing an optional string to the compiler.
Every C Program will have one or more functions and there is one mandatory function
which is called main() function. This function is prefixed with keyword int which means this
function returns an integer value when it exits. This integer value is returned using return
statement.
Symbolic constants are usually written in upper case to distinguish them from lower case
variables. Values defined here remain constant throughout the program.