Nothing Special   »   [go: up one dir, main page]

Objectives: Having Read This Module The Students Should Be Able To

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Module 1: Introduction to C Programming

Objectives: Having read this module the students should be able to:

• Understand the general overview of the C programming language.


• Understand the cycle of C programming.

A Brief History of C

Many of the important ideas of C stem from the language BPCL (Basic Combined
Programming Language), 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 PDP-7. BCPL and B are “typle less”
languages whereas C provides a variety of data types.

In 1972, Dennis Ritchie at Bell Labs writes C 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 C. The resulting definition, the ANSI
standard, or “ANSI C”, was completed late 1988.

Why use C?

C has been used successfully for every type of programming problem imaginable from
operating systems to spreadsheets to expert systems – and efficient compilers are
available for machines ranging in power from the Apple Macintosh to the Cray
supercomputers. The largest measure of C’s success seems to be based on purely
practical considerations:

• The portability of the compiler


• The standard library concept
• A powerful and varied repertoire of operators
• An elegant syntax
• Ready access to the hardware when needed
• And the ease with which applications can be optimized by procedures

C is often called a “Middle Level” programming language. This is not a reflection on its
lack of programming power but more a reflection on its capability to access the system’s
low level functions. Most high-level languages provide everything the programmer might
want to do already built into the language. A low level language (e.g. assembler) provides
nothing other than access to the machines basic instruction set. A middle level language,
such as C, probably doesn’t supply all the constructs found in high-languages – but it
provides all the building blocks that you will need to produce the results you want!

Uses of C

C was initially used for system development work, in particular the programs that make-
up the operating system. C produces code that runs nearly as fast as code written in
assembly language.

Some examples of the uses of C might be:

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

The Programming Cycle

Developing a program in a compiled language such as C requires at least four steps:

1. Editing
2. Compiling
3. Linking
4. Executing

We will now cover each step separately.

Editing

You write a computer program with words and symbols that are understandable to human
beings. This is the editing part of the development cycle. You type the program directly
into a window on the screen and save the resulting text as a separate file. This is often
referred to as the source file. The custom is that the text of a C program is stored in a
file with the extension .c for C programming language.

Compiling

You cannot directly execute the source file. To run on any computer system, the source
file must be translated into binary numbers understandable to the computer’s Central
Processing Unit. This process produces an intermediate object file – with extension .obj,
which stands for ‘object’.

Linking

Why is linking necessary? The main reason is that many compiled languages come with
library routines which can be added to your program. These routines are written by the
manufacturer of the compiler to perform a variety of tasks, from input/output to
complicated mathematical functions. In the case of C standard input and output functions
are contained in a library (stdio.h) so even the most basic program will require a library
function. After linking the file extension becomes .exe which turns to be an executable
file.

Executing

Thus the text editor produces .c source files, which go to the compiler, which produces
.obj object files, which go to the linker, which produces .exe executable file. You can then
run .exe files to see its output.

If your get an error message, or you find that the program doesn’t work when you finally
run it you will have to go back to the source file - .c file – to make changes and go through
the whole development process again.

Reference:

Quinito, Floreto Jr. (S.Y. 2009 – 2010). C Programming - IT12 Course and
Laboratory Manual Second Edition. CM Recto Ave. Lapasan, Cagayan De Oro City,
Publisher: Mindanao University of Science and Technology.

You might also like