"C" Programming Language
"C" Programming Language
What is language ?
Language is medium of communication.
If two persons want to communicate with each other , they
have to use a common language.
Like Hindi, English, Punjabi .
Machine Language
Assembly language
C++
JAVA
:.NET
Programming languages
Various programming languages
Some understandable directly by computers
Others require translation steps
Machine language
Natural language of a particular computer
Consists of strings of numbers(1s, 0s)
Instruct computer to perform elementary operations
one at a time
Machine dependant
Programming languages
Assembly Language
English like abbreviations
Translators programs called Assemblers to convert
assembly language programs to machine language.
E.g. add overtime to base pay and store result in gross pay
LOAD
BASEPAY
ADD
OVERPAY
STORE
GROSSPAY
Programming languages
High-level languages
To speed up programming even further
Single statements for accomplishing substantial tasks
Translator programs called Compilers to convert highlevel programs into machine language
E.g. add overtime to base pay and store result in gross pay
grossPay = basePay + overtimePay
Types of Translator
SOURCE
CODE
SOURCE
CODE
SOURCE
CODE
Compiler
OBJECT
CODE
Interpreter
OBJECT
CODE
Assembler
OBJECT
CODE
Basics of C
Why use C?
Mainly because it produces code that runs nearly as fast as
code written in assembly language. Some examples of the use
of C might be:
Operating Systems
Language Compilers
Assemblers
Text Editors
Print Spoolers
Network Drivers
Modern Programs
Data Bases
Language Interpreters
Utilities
Development with C
Four stages
Editing: Writing the source code by using some IDE or editor
Preprocessing or libraries: Already available routines
compiling: translates or converts source to object code for a
specific platform
source code -> object code
linking: resolves external references and produces the
executable module
Portable programs will run on any machine but..
Program correctness and robustness are most important than
program efficiency
History
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.
The Beginning of C
BCPL B
Martin Richards
-
Ken Thompson
Dennis Ritchie
History of C
Evolved from two previous languages
BCPL , B
BCPL (Basic Combined Programming Language) used for
writing OS & compilers
B used for creating early versions of UNIX OS
Both were typeless languages
C language evolved from B (Dennis Ritchie Bell labs)
C was developed by Dennis Ritchie at AT & T bell laboratory
of USA in 1972.
History of C
Hardware independent
Programs portable to most computers
Dialects of C
Common C
ANSI C
ANSI/ ISO 9899: 1990
Called American National Standards Institute ANSI C
Case-sensitive
Application Areas Of C
C was initially used for systems programming.
A system program forms a portion of the operating
system of the computer or its support utilities.
Operating Systems, Interpreters, Editors, Assembly
programs are usually called system programs.
The UNIX operating system was developed using C.
There are C compilers available for almost all types
of PCs.
A simple Program of C
/* Write a program to print a message */
#include<stdio.h>
#include<conio.h>
void main()
{
printf( C Programming);
getch( );
}
Basics of C Environment
C systems consist of 3 parts
Environment
Language
C Standard Library
Development environment has 6 phases
Edit
Pre-processor
Compile
Link
Load
Execute
Basics of C Environment
Phase 1
Editor
Phase 2 Preprocessor
Phase 3
Phase 4
Compiler
Linker
Disk
Program edited in
Editor and stored
on disk
Disk
Preprocessor
program processes
the code
Disk
Disk
Basics of C Environment
Primary memory
Phase 5
Loader
Primary memory
Phase 6
CPU
Puts program in
memory
SHORT CUT
FILE NAME
Save
Compile
F2
Alt + F9
abc.c
abc.obj
Execute
Ctrl + F9
abc.exe
Back up
Again F2
abc.bak
Escape Sequence
\n
\t
\r
\a
\\
\
new line
tab
carriage return
alert
backslash
double quote
Thanks