PROGRAMMING IN C
UNIT-I
OVERVIEW OF C
Overview of C
HISTORY OF C
Dennis M. Ritchie, a systems engineer at Bell Laboratories, New Jersey developed C in 1972. C was
evolved from ALGOL(Algorithmic Language), BCPL (Basic Combined Programming Language)and B.
Since ‘C’ was developed along with UNIX operating system, it is strongly associated with UNIX. This
operating system was coded almost entirely in C. To assure that the C language remains standard, in1983,
American National Standards Institute(ANSI) appointed a technical committee to define a standard for C.
The committee approved a version of C in December 1989 which is known as ANSI C. It was then ap -
proved by the International Standards Organization(ISO) in 1990. This version is also referred to as C89.
The last version of C is C99.
The main features of C language include low-level access to memory, simple set of keywords, and clean
style, these features make C language suitable for system programming like operating system or compiler
development.
History of ANSI C
Page 1 of 5
PROGRAMMING IN C
UNIT-I
OVERVIEW OF C
IMPORTANCE OF C (SALIENT FEATURES OF C)
‘C’ is a block structured language, may be viewed as a group of building blocks called functions.
(A function is part of the program designed to do a specific task.)
It is a robust language whose rich set of built-in functions and operators can be used to write any
complex program.
It is a middle level language, hence suitable for developing application software as well as system
software.
Programs written in C are efficient and fast. This is due to its variety of data types and powerful
operators.
Programs written in C are found to execute faster than compared to other languages.
There are only 32 keywords. This makes the language simple, orderly and can be learned within a
short time.
C is highly portable. This means that C program written for one computer can be run on another
with little or no modification.
C language is well suited for structured programming. The modular structure makes program
debugging, testing and maintenance easier.
We can add our own functions to C library.
Many compilers available in market are written in ‘C’.
BASIC STRUCTURE OF A C PROGRAM
C program can be viewed as a group of building blocks called functions. A function is a
subroutine that may include one or more statements designed to perform a specific task. To write a C
program, we first create functions and then put them together. A C program may contain one or more
sections as shown below.
Document section
Link section
Definition section
Global declaration section
main() function section
{
Declaration part
Executable part
Page 2 of 5
PROGRAMMING IN C
UNIT-I
OVERVIEW OF C
}
Subprogram section (User-defined functions)
Function 1
Function 2
.
.
.
Function n
◊ The document section consists of a set of comment lines giving the name of the program, the
author and other details, which the program would like to use later.
◊ The link section provides instructions to the compiler to link functions from the system library.
◊ The definition section defines all symbolic constants.
◊ Global variables are declared in the global declaration section. The variables which are used in
more than one function are called global variables and declared outside of all the functions.
◊ Every C program must have one main()function section, which is the identification for the start
of the main part of the program. This section contains two parts, declaration part and executable
part.
◊ The declaration part declares all the variables used in the executable part
◊ There is at least one statement in the executable part.
◊ The closing brace of the main function section is the logical end of the program.
◊ All statements in the declaration and executable parts end with semicolon.
◊ The subprogram section contains all the user-defined functions that are called in the main
function.
◊ All sections, except the main function may be absent when they are not required.
Example:
/* Program to calculate area of a circle */ Document section
#include<stdio.h> Link section
#define PI 3.14159 Definition section
main() main()function section
Page 3 of 5
PROGRAMMING IN C
UNIT-I
OVERVIEW OF C
int radius;
Declaration
float area;
part
printf("Enter the radius of a circle ");
scanf("%d",&radius);
Executable
area=PI*radius*radius;
part
printf("Area of a circle=%.2f",area);
Executing a C program
Executing a program written in C involves a series of steps. These are:
1. Creating the program
2. Compiling the program
3. Linking the program with functions that are needed from the C library
4. Executing the program
Page 4 of 5
PROGRAMMING IN C
UNIT-I
OVERVIEW OF C
Page 5 of 5