Basic Intro For C
Basic Intro For C
PROGRAMMING
Introduction to C Programming
What is a program?
A list of instructions.
Written in a programming language (c, c++, java).
Determines the behavior of a machine
(computer, robot).
Programming Language
A machine language that has its own set of
grammatical rules.
It is used to instruct a machine to perform
specific tasks.
History
C was developed in 1972 by Dennis Ritchie at
Bell Laboratories.
Based on a programming language called B
(which is derived from BCPL language).
C was designed and developed for the
development of UNIX operating system.
C has been widely used to develop many type
of application software from a basic to
operating system.
Christopher
Strachey
Uni. Cambridge
& Uni. London
Complex thus
not popular
Martin Richards
Powerful and
Portable
One data type
Ken Thompson
& Dennis Ritchie
Bell Labs
One data type
1972
BCPL
1969
CPL (Combined
Programming
Language)
1966
1963
History
C
Dennis Ritchie
at Bell
Laboratories
Based on a
programming
language called
B
Designed and
developed for
the
development of
UNIX operating
system
Editing
Process of writing the C source code.
Using editor program (i.e. vi and emacs for
Linux, Notepad for Windows)
Software package provides programming
environment
Integrated editor
Managing and maintaining source code
i.e. C++ Builder, Code::Blocks, Dev-C++, Microsoft
Visual Studio
Linking
Process of combining generated object files.
Add required codes from C standard library.
Produce an executable file.
Executing
Run the program to check whether it produce
the desired output.
Testing stage where you check the output of
your program.
The program does not produces the suppose
output, then you have made logic (semantic)
error.
C Program Layout
C program consists of two sections:
Pre-processor directives
Main function
pre-processor directives
main()
Pre-processor section
{
Main function section
statements
}
Pre-processor Directives
Specify what compiler should do before
compilation.
Include header files.
Header file keep information about the library
functions (printf, scanf).
Pre-processor directives begins with the #
symbol.
Main Function
The program starts its execution.
Define the program definition.
An Example of C Program
Sample output:
C program example
Additional - Comments
A comment, not actually part of the program.
Provide information on what the program
does.
Begin with /* and end with */ or written as
//.
Good habit to include comments.
Keep inform what are the code actually doing.
Important line in C
Symbol # indicates that this is a pre-processor
directive
Include stdio.h header file in our program
stdio.h contains information on
input/output routines.
We are using the printf() function from
stdio.h