0% found this document useful (0 votes)
54 views28 pages

CSE101 Computer Programming: Lecture #0

BEgineer

Uploaded by

t iwari
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
54 views28 pages

CSE101 Computer Programming: Lecture #0

BEgineer

Uploaded by

t iwari
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd

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

Common questions

Powered by AI

The compilation of a C program involves four stages: preprocessing, compilation, assembly, and linking. Preprocessing interprets lines starting with # as commands to reduce repetition through macros or include files. Compilation translates preprocessed code into assembly instructions specific to the processor architecture, forming an intermediate language. Assembly converts these instructions into object code in binary format. Finally, linking organizes these machine instructions, rearranging and completing any missing segments to produce an executable program .

The development of C during the creation of UNIX provided solutions to existing limitations in language portability and low-level operations. Its historical context emphasizes adaptability and resource efficiency, which are encapsulated in its design. These features, combined with its influence over successive languages like C++, contributed to C's widespread adoption. Developers appreciate its balance of power and flexibility, making it a mainstay in programming education and practice .

The assembly stage translates the assembly instructions generated from the compilation stage into object code, providing a binary format of the instructions that a processor can execute directly. This stage ensures that the code is optimized for execution efficiency, minimizing runtime errors and facilitating precise control over processor behavior. It results in the creation of a file containing machine-level instructions, making it pivotal for achieving optimal program performance .

C was developed to provide portability that its predecessors lacked. Dennis Ritchie and Ken Thompson required a new language for UNIX's development because their existing language did not support this feature. C was derived from the B language and incorporated elements from its predecessors like BCPL, making it more suitable for operating system development with improved support for low-level operations, modularity, and feature richness .

C's support for modular programming allows developers to break down complex software into manageable, interchangeable modules. This feature enhances code readability, maintainability, and reusability, reducing development time and effort. It also facilitates collaborative development, where different modules can be worked on simultaneously by different teams, integrating seamlessly into a cohesive whole. This modularity has substantial implications for large-scale software projects and system stability .

C is considered a low-level language because it provides direct manipulation of hardware and memory through pointers and other constructs. At the same time, it offers high-level features like modular programming and portability, enabling complex software development with abstractions over the hardware. This duality makes C powerful and versatile, suitable for writing operating systems, embedded software, and compilers .

The preprocessing stage is the first step in compiling a C program, where lines starting with # are interpreted as preprocessor directives. This stage enables code efficiency through macros, file inclusions, and conditional compilation, reducing repetition and optimizing the source code. The outcomes of preprocessing streamline the transition to the next compilation stage by preparing and optimizing code structure .

The C programming language was named as such because it was developed after the B language, borrowing many of its principles. The B language itself was derived from BCPL, which was a descendant of the Combined Programming Language (CPL). The sequential naming from B to C signifies the language's evolutionary advancements from its predecessors, with C being a more sophisticated version that addressed specific needs in portability and modularity .

Historically, C has laid the foundation for many modern languages and software systems. Its efficiency and flexibility make it suitable for low-level programming and system development. C's influence is evident in companies' ongoing demand for C programmers, as many infrastructures, such as database systems, operating systems, and embedded systems, are built using C. This demand remains high among top-rated companies, reflecting C's enduring importance and relevance in developing performance-critical applications .

The C programming language remains relevant because it is foundational, influencing many modern programming languages, including Python and PHP, whose compilers are written in C. Additionally, C is integral to system software, as the latest version of Microsoft Windows and many device drivers are written in it. Its use extends to embedded systems, databases, and operating systems like Linux and Unix, largely due to its portability and low-level functionality .

You might also like