Вы находитесь на странице: 1из 28

CSE101

Computer Programming
Lecture #0

© LPU :: CSE101 C Programming


Course Details
• Text Book
 “PROGRAMMING IN C”
by
ASHOK N. KAMTHANE
PEARSON, 2nd Edition

© LPU :: CSE101 C Programming


Reference Books
• “C HOW TO PROGRAM” by
PAUL DEITEL AND
HARVEY DEITEL
PHI(Prentice Hall India) 7TH Edition

• “PROGRAMMING IN ANSI C”
By E. BALAGURUSAMY
McGraw Hill Education
6th Edition
© LPU :: CSE101 C Programming
WHY C???????????????

If we have number of powerful


programming languages available
with us then why c??????

© LPU :: CSE101 C Programming


Popular Programming Ratings

© LPU :: CSE101 C Programming


The hitch...............
Some burning questions in mind......
• C is a very old language. Why are we still studying
this language??????
• Now, we have very powerful languages with us
then, why c??
• There is no scope of this language in industry

© LPU :: CSE101 C Programming


Lets take you close to the reality
• All of us use Computers or Laptops for different
purposes.
• Could you tell me which system software is most
required to get our system in working mode??????

© LPU :: CSE101 C Programming


Let’s Explore more
• Could you tell me which programming language is
used in writing all these operating system??????

• Latest version of Microsoft Windows i.e.


Windows10 is still being written in C Language

© LPU :: CSE101 C Programming


Contd.....
• Device drivers are also written in C language.
• All these modern programming languages are
influenced by C language

• Compilers for Python and PHP language are also


written in C language

© LPU :: CSE101 C Programming


Contd.....
• Embedded systems are also developed with the
help of C language

© LPU :: CSE101 C Programming


Contd.....
•Git

•Microsoft Excel

•Oracle Database

•MySql

•Linux

•Unix

•Android

•Google
© LPU :: CSE101 C Programming
MNCs
Top rated Companies which has a dearth of C programmers

© LPU :: CSE101 C Programming


Here are the Answers of Questions
• C is very a old language still, why do we study C
language??

• Now, we have very powerful languages


with us then why c??

• There is no scope of this language in industry

© LPU :: CSE101 C Programming


History of C
• Guys Can you make a sentence with the word
‘Necessity’
“Necessity is the mother of invention”
• Dennis Ritchie and Ken Thompson were working
on developing a new operating system i.e UNIX
• But the programming language they
were using was not providing them
the portability feature
• So Dennis Ritchie developed new
language i.e C
© LPU :: CSE101 C Programming
History continued...

© LPU :: CSE101 C Programming


Why “C” name was given???
• Many of C’s principles and ideas were derived from the
earlier language B. (Ken Thompson was the developer of
B Language.)
• BCPL and CPL are the earlier ancestors of B Language
• CPL is Combined Programming Language. In 1967, BCPL
Language ( Basic CPL ) was created as a scaled down
version of CPL
• As many of the features were derived from “B”
Language thats why it was named as “C”.
• After 7-8 years C++ came into existence which was first
example of object oriented programming .
© LPU :: CSE101 C Programming
Evolution of C...

© LPU :: CSE101 C Programming


Language Developers

© LPU :: CSE101 C Programming


Features of C Language
• Low Level Language Support
• Program Portability
• Powerful and Feature rich
• High Level Features
• Modular Programming

© LPU :: CSE101 C Programming


Applications of C
• Used for creating computer applications
• Used in writing embedded software
• Development of Simulators
• Used for creating compilers
• Used to implement different operating system
operations
• UNIX kernel is completely developed in C
language

© LPU :: CSE101 C Programming


Course Contents
Before MTE After MTE
•Data Types & Operators •Pointers
•Control Structures •Dynamic Memory
Allocation

•User Defined Functions •Derived Data Types –


Structures & Unions

•Storage Classes

•Arrays and Strings


© LPU :: CSE101 C Programming
Program
Development
Program in
CDevelopment in
C

© LPU :: CSE101 C Programming


Stages of Compiling a C Program
• Four Stages of Compiling a C Program
– Preprocessing
– Compilation #include<stdio.h>
int main(void) {
– Assembly
puts("Hello, World!");
– Linking
return 0;
}

© LPU :: CSE101 C Programming


What a pre-processor will do?
• The first stage of compilation is called
preprocessing.
• In this stage, lines starting with a #character are
interpreted by the preprocessor as preprocessor
commands.
• These commands form a simple macro language
with its own syntax and semantics.
• This language is used to reduce repetition in
source code by providing functionality to inline
files, define macros, and to conditionally omit
code.
© LPU :: CSE101 C Programming
After Preprocessing

extern int __vsnprintf_chk (char * restrict, size_t,


int, size_t, const char * restrict, va_list);
# 493 "/usr/include/stdio.h" 2 3 4
# 2 "hello_world.c" 2

int main(void) {
puts("Hello, World!");
return 0;
}
© LPU :: CSE101 C Programming
Compilation Stage
• In this stage, the preprocessed code is translated to
assembly instructions specific to the target
processor architecture.
• These form an intermediate human readable
language.
• The existence of this step allows for C code to
contain inline assembly instructions and for
different assemblers to be used.
• This will create a file named hello_world.s
containing the generated assembly code.
© LPU :: CSE101 C Programming
Assembly Stage
• An assembler is used to translate the assembly
instructions to object code.
• The output consists of actual instructions to be run
by the target processor.
• It will create a file named hello_world.o
containing the object code.
• Content of the file is in binary format

© LPU :: CSE101 C Programming


Linking
• The object code generated in the assembly stage is
composed of machine instructions that the
processor understands.
• But some pieces of the program are out of order or
missing.
• To produce an executable program, the existing
pieces have to be rearranged and the missing ones
filled in.
• This process is called linking.

© LPU :: CSE101 C Programming

Вам также может понравиться