OVER
VIEW OF C
D.Seethalakshmi MCA.,M.Phil.,
Assistant Professor
Bon Secours College for women
Thanjavur
FATHEROF‘C’L
A
N
G
U
A
G
E
INTRODUCTION
• C is one of the most popular computer languages today.
• C language has evolved from three different structured language ALGOL, BCPL and
B language.
• C was an offspring of the ‘Basic Combined Programming Language’(BCPL) called
B language, developed at Cambridge University in 1960.
• B language invented by Ken Thompson developed by Martin Richards.
• B language was modified by Dennis Ritchie at AT& T’s Bell laboratories in 1972.
• The new language was named C.
• C adopted by ‘American National Standard Institute’(ANSI).
• In 1990, a version of C language was approved by the ‘International Standard
Organisation’(ISO) and that version of C is also referred to as C89 and C99.
HISTORYOFC
Y
e
a
r Developedby
1960 International Group
1967 Martin Richard
1970 Ken Thompson
1973 Dennis Ritchie
1989 ANSI Committee
1990 ISO Committee
ALGOL
BCPL
B
Traditional C
ANSI C
ANSI/ISO C
FEATURESOFC
• C has been written in assembly language.
• C is a high-level structured oriented programming language.
• C is a robust language with rich set of built-in function and operators.
• Programs written in C are efficient and fast.
• C is highly portable, programs once written in C can be run on another machines
with minor or no modification.
• C is basically a collection of C library functions, we can also create our own
function and add it to the C library.
• C is easily extensible.
• One of the early programming languages.
• Still the best programming language to learn quickly.
• C language is reliable, simple and easy to use.
• C language is a structured language.
• Modern programming concepts are based on C.
• It can be compiled on a variety of computer platforms.
• Universities preferred to add C programming in their courseware.
• C program can be viewed as a group of building blocked called function.
APPLICATIONS
C language has widely uses, some main uses are given below.
• Used to develop software's that control embedded systems. Examples of some
embedded system are Washing machine, Microwave oven, etc.
• For creating computer applications.
• UNIX Operating System is developed in C language.
BASICSTRUCTUREOFCPROGRAM
Moresection
Documentation Section
link Section
Definition Section
Global Declaration Secation
{
Declaration Part
Executable Part
}
Subprogram Section
Function 1
( User – defined
Function)
Function 2
.
.
Function n
E
X
A
M
P
L
E
#include<studio.h> / link section /
int total=0; / Global declaration and definition section /
int sum(int,int); / Function declaration section /
int main() / main function /
{
printf(“ this is a C programn”);
total=sum(1,1);
printf(“sum of two numbers:%dn”, total);
return 0;
}
int sum(int a, int b) / User defined function /
{ / Definition section /
return a+b;
}
DESCRIPTION FOREACH SECTION
DocumentationSection:
we can give comment about the program, create or modified
date, author name etc.
The character or words or anything which are given between
“/*” and “*/”, won’t be considered by C compiler for compilation process.
There will be ignored by C compiler during compilation.
LinkSection:
The link section consists of the header files of the functions that
are used in the program.
It provides instructions to the compiler to link functions from the
system library.
C
O
N
T
.
…
DefinitionSection:
All the symbolic constants are written in definition section. Macros
are know as symbolic constants.
GlobalDeclarationSection:
The global variables that can be used anywhere in the program are
declared in global declaration section.
This section also declares the user defined functions.
FUNCTIONP
R
O
T
O
T
Y
P
EDECLARA
TIONS
E
C
T
I
O
N
:
Function prototype give many information about a function like
return type, parameter names used inside the function
CONT
.
…
.main()Functionsection:
Every C program is started from main function and this function
contain two major sections called
Declaration Section and
Executable Section.
Declaration section declares all the variables that are used in executable part.
UserDefinedFunctionSection:
User can define their own function in this section which perform
particular task as per the user requirement.
EXECUTING A “C” PROGRAM
Executing a program written in C involves a series of step.
There are:
Creating the Program.
Compiling the program.
Linking the program with function that are needed from the C library.
Executing the program.
PROCESS OF COMPILING AND
RUNNING A C PROGRAM
COMPILER
Definitionofcompiler:
A Compiler is computer software that translate source code into
object code.
The compilation proceeds silently and the translated program is stored on
another file with the name eg.o.
This program is known as object code.
LINKING is the process of putting together other program files and functions
that are required by the program.
If any mistakes in the syntax and semantics of the language, listed out and the
compilation process ends.
The error should be corrected source program with the help of the editor and
the compilation done again.
Executing the program
Execution is simple task.
Sometimes the program does not produce the desired result… the program has
error in logical or data.
Correct the source program or the data.
After modification the entire process of compiling, linking and executing the
program should be repeated.
Creating own Executable file
Same name of the file will be overwritten the exeucutable object code of the
new program.
Prevent this, we should rename the file immediatedly.
Multiple Source Files
file name – m1.c m2.c
creating object to link multiple files using CC
cc m1.o m2.o
also combine source file and object file also
cc m1.c m2.o
SOME BASIC SYNTAX RULE
FOR C PROGRAM
• C is a case sensitive language so all C instruction must be written in lower case
letter.
• All C statement must be end with a semicolon.
• Whitespace is used in C describe blanks and tabs.
• Whitespace is required between keywords and identifiers.
S
A
M
P
L
ECP
R
O
G
R
A
M
#include<studio.h>
main( )
{
printf(“hi slide share”);
}
output:
hi slide share
PROGRAM
EXPLANATION
HeaderFile:
standard input and output (predefined)
#include<studio.h>
pre-processor directive
The pre-processor is a software program that will expand the source code while theprogram
is compiled.
pre-defined is used to display the results on the standardoutput.
Syntax:
#include<path-space>
< > angle-bracket form, pre-processor to search the directories that are specified bythe
include.
CONT.
…
.
main( )
This is the point where the execution begins when the program is run.
main( ) is the calling and also user-defined function.
{ } – name of parentheses (the two brackets properly called Braces).
This indication to the compiler that this is a function.
“ ” – The end result is that whatever is included between the Quotation marks
will be displayed on the monitor when the program is run.
CONT
.
…
.
; (semi-colon) – used as a statement Terminator.
so is required as a signal to the compiler that this line is complete.
printf (executable statement) – is the predefined, standard C function for printing
output.
n (new line character) – C compiler consider the combination of the(black lash)
and (letter n) as a one character. So it return the cursor to
the left side of the monitor and print the new line.
ADVANTAGES
• C is the building block for many other programming languages.
• Programs written in C are highly portable languages.
• Several standard functions are the (like in-built) that can be used to develop
programs.
• C program are basically collections of C library function, and it’s also easy to add
own function in to the C library.
• The modular structure make code debugging, maintenance and testing easier.
DISADVANTAGES
• C does not provide Object Oriented Programming(OOP) concepts.
• There is no runtime checking in C language.
• There is no strict type checking.
Example, we can pass on integer value.
• There is no concepts of Namespace in C.
• C does not provided binding or wrapping up of data in a single unit.
• C does not provide Constructor and Destructor.
MS-DOS SYSTEM
The file name should end with the characters “C” eg pay.c.
MS-DOS operating system would load the program stored in the pay.c and
generate the object code.
This code is stored in another file under name pay.obj.

chapter 1.pptx

  • 1.
    OVER VIEW OF C D.SeethalakshmiMCA.,M.Phil., Assistant Professor Bon Secours College for women Thanjavur
  • 2.
  • 3.
    INTRODUCTION • C isone of the most popular computer languages today. • C language has evolved from three different structured language ALGOL, BCPL and B language. • C was an offspring of the ‘Basic Combined Programming Language’(BCPL) called B language, developed at Cambridge University in 1960. • B language invented by Ken Thompson developed by Martin Richards. • B language was modified by Dennis Ritchie at AT& T’s Bell laboratories in 1972. • The new language was named C. • C adopted by ‘American National Standard Institute’(ANSI). • In 1990, a version of C language was approved by the ‘International Standard Organisation’(ISO) and that version of C is also referred to as C89 and C99.
  • 4.
    HISTORYOFC Y e a r Developedby 1960 InternationalGroup 1967 Martin Richard 1970 Ken Thompson 1973 Dennis Ritchie 1989 ANSI Committee 1990 ISO Committee ALGOL BCPL B Traditional C ANSI C ANSI/ISO C
  • 5.
    FEATURESOFC • C hasbeen written in assembly language. • C is a high-level structured oriented programming language. • C is a robust language with rich set of built-in function and operators. • Programs written in C are efficient and fast. • C is highly portable, programs once written in C can be run on another machines with minor or no modification. • C is basically a collection of C library functions, we can also create our own function and add it to the C library. • C is easily extensible.
  • 6.
    • One ofthe early programming languages. • Still the best programming language to learn quickly. • C language is reliable, simple and easy to use. • C language is a structured language. • Modern programming concepts are based on C. • It can be compiled on a variety of computer platforms. • Universities preferred to add C programming in their courseware. • C program can be viewed as a group of building blocked called function.
  • 7.
    APPLICATIONS C language haswidely uses, some main uses are given below. • Used to develop software's that control embedded systems. Examples of some embedded system are Washing machine, Microwave oven, etc. • For creating computer applications. • UNIX Operating System is developed in C language.
  • 8.
    BASICSTRUCTUREOFCPROGRAM Moresection Documentation Section link Section DefinitionSection Global Declaration Secation { Declaration Part Executable Part } Subprogram Section Function 1 ( User – defined Function) Function 2 . . Function n
  • 9.
    E X A M P L E #include<studio.h> / linksection / int total=0; / Global declaration and definition section / int sum(int,int); / Function declaration section / int main() / main function / { printf(“ this is a C programn”); total=sum(1,1); printf(“sum of two numbers:%dn”, total); return 0; } int sum(int a, int b) / User defined function / { / Definition section / return a+b; }
  • 10.
    DESCRIPTION FOREACH SECTION DocumentationSection: wecan give comment about the program, create or modified date, author name etc. The character or words or anything which are given between “/*” and “*/”, won’t be considered by C compiler for compilation process. There will be ignored by C compiler during compilation. LinkSection: The link section consists of the header files of the functions that are used in the program. It provides instructions to the compiler to link functions from the system library.
  • 11.
    C O N T . … DefinitionSection: All the symbolicconstants are written in definition section. Macros are know as symbolic constants. GlobalDeclarationSection: The global variables that can be used anywhere in the program are declared in global declaration section. This section also declares the user defined functions. FUNCTIONP R O T O T Y P EDECLARA TIONS E C T I O N : Function prototype give many information about a function like return type, parameter names used inside the function
  • 12.
    CONT . … .main()Functionsection: Every C programis started from main function and this function contain two major sections called Declaration Section and Executable Section. Declaration section declares all the variables that are used in executable part. UserDefinedFunctionSection: User can define their own function in this section which perform particular task as per the user requirement.
  • 13.
    EXECUTING A “C”PROGRAM Executing a program written in C involves a series of step. There are: Creating the Program. Compiling the program. Linking the program with function that are needed from the C library. Executing the program.
  • 14.
    PROCESS OF COMPILINGAND RUNNING A C PROGRAM
  • 15.
    COMPILER Definitionofcompiler: A Compiler iscomputer software that translate source code into object code.
  • 16.
    The compilation proceedssilently and the translated program is stored on another file with the name eg.o. This program is known as object code. LINKING is the process of putting together other program files and functions that are required by the program. If any mistakes in the syntax and semantics of the language, listed out and the compilation process ends. The error should be corrected source program with the help of the editor and the compilation done again.
  • 17.
    Executing the program Executionis simple task. Sometimes the program does not produce the desired result… the program has error in logical or data. Correct the source program or the data. After modification the entire process of compiling, linking and executing the program should be repeated.
  • 18.
    Creating own Executablefile Same name of the file will be overwritten the exeucutable object code of the new program. Prevent this, we should rename the file immediatedly. Multiple Source Files file name – m1.c m2.c creating object to link multiple files using CC cc m1.o m2.o also combine source file and object file also cc m1.c m2.o
  • 19.
    SOME BASIC SYNTAXRULE FOR C PROGRAM • C is a case sensitive language so all C instruction must be written in lower case letter. • All C statement must be end with a semicolon. • Whitespace is used in C describe blanks and tabs. • Whitespace is required between keywords and identifiers.
  • 20.
  • 21.
    PROGRAM EXPLANATION HeaderFile: standard input andoutput (predefined) #include<studio.h> pre-processor directive The pre-processor is a software program that will expand the source code while theprogram is compiled. pre-defined is used to display the results on the standardoutput. Syntax: #include<path-space> < > angle-bracket form, pre-processor to search the directories that are specified bythe include.
  • 22.
    CONT. … . main( ) This isthe point where the execution begins when the program is run. main( ) is the calling and also user-defined function. { } – name of parentheses (the two brackets properly called Braces). This indication to the compiler that this is a function. “ ” – The end result is that whatever is included between the Quotation marks will be displayed on the monitor when the program is run.
  • 23.
    CONT . … . ; (semi-colon) –used as a statement Terminator. so is required as a signal to the compiler that this line is complete. printf (executable statement) – is the predefined, standard C function for printing output. n (new line character) – C compiler consider the combination of the(black lash) and (letter n) as a one character. So it return the cursor to the left side of the monitor and print the new line.
  • 24.
    ADVANTAGES • C isthe building block for many other programming languages. • Programs written in C are highly portable languages. • Several standard functions are the (like in-built) that can be used to develop programs. • C program are basically collections of C library function, and it’s also easy to add own function in to the C library. • The modular structure make code debugging, maintenance and testing easier.
  • 25.
    DISADVANTAGES • C doesnot provide Object Oriented Programming(OOP) concepts. • There is no runtime checking in C language. • There is no strict type checking. Example, we can pass on integer value. • There is no concepts of Namespace in C. • C does not provided binding or wrapping up of data in a single unit. • C does not provide Constructor and Destructor.
  • 26.
    MS-DOS SYSTEM The filename should end with the characters “C” eg pay.c. MS-DOS operating system would load the program stored in the pay.c and generate the object code. This code is stored in another file under name pay.obj.