0% found this document useful (0 votes)
6 views70 pages

FOC Unit 1A Slides

Uploaded by

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

FOC Unit 1A Slides

Uploaded by

abishekcr5
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 70

M.S.

Ramaiah Institute of Technology


(Autonomous Institute, Affiliated to VTU)
Department of Computer Science and Engineering

Course Name: Computing Fundamentals and C Programming


Course Code: CS14/24
Credits: 2:1:0
UNIT -1
Term: December 2021 – March 2022
Prepared by: Dr. Sangeetha. V
Sanjeetha. R

Reference: Reema Thareja - Programming in C, Oxford University press 2nd Edition, 2015

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 1


UNIT 1 Syllabus covered
Introduction to Programming: Introduction to Computer Software, Classification
of Computer Software-System Software, Application Software, Programming
Languages, Generation of Programming Languages, Introduction to C-
Introduction, Background, Characteristics of C, Uses of C.

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 2


OUTLINE
Introduction to Programming
◦ Introduction to Computer Software
◦ Classification of Computer Software
◦ System Software
◦ Application Software
◦ Programming Languages
◦ Generation of Programming Languages
Introduction to C
◦ Background
◦ Characteristics of C
◦ Uses of C
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 3
Introduction to Computer Software
Computer
◦ A computer is an electronic device that is designed to accept data,
perform the required mathematical and logical operations at high
speed and output the result.
◦ A computer accepts data, processes it, and produces information.
◦ Data refers to some raw facts or figures.
◦ Information is the processed data.

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 4


Introduction to Computer Software
Computer
◦ Figure shows parts of a Computer system
Computer System

Computer Hardware Computer Software

System Software Application Software

◦ Computer hardware does all the physical work computers are known for.
◦ Computer Software commands the hardware.

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 5


Introduction to Computer Software
Computer Hardware
◦ Computer hardware is a digital machine, it can only understand
two basic states: on and off.
◦ Computer hardware cannot think and make decisions on its own.
◦ Hardware needs a software to instruct what has to be done.

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 6


Introduction to Computer Software
Computer Software
◦ Computer software is written by computer programmers using a
programming language.
◦ Programmers writes a set of instructions using a specific
programming language. Such instructions are known as Source
code
◦ Program: A set of instructions that are arranged in a sequence to
guide a computer to find a solution for a given problem.
◦ Programming: The process of writing a program is called
Programming

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 7


Introduction to Computer Software
Computer Software
Examples of computer software includes:
◦ Computer games
◦ Driver software
◦ Educational software
◦ Media players and Media development software
◦ Productivity software
◦ Operating system software

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 8


Classification of Computer Software
Computer software can be broadly classified into two groups:
◦ System software
◦ Application software

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 9


Classification of Computer Software
System software
◦ System software provides a general programming environment in which
programmers can create specific applications to suit their needs.
◦ System software represents programs that allow the hardware to run
properly.
◦ System software is transparent to the user and acts as an interface between
the hardware of the computer and the application software that users need to
run on the computer.

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 10


Classification of Computer Software
System software
◦ Figure illustrates the relationship
between application software,
system software, and hardware.

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 11


Classification of Computer Software
System software
◦ System software is software designed to operate the computer
hardware and to provide and maintain a platform for running
application software
◦ The most widely used system software are:
◦ Computer BIOS and Device Drivers
◦ Operating System
◦ Utility Software
◦ Compiler, Interpreter, Linker, and Loader

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 12


Classification of Computer Software
Computer BIOS and Device Drivers
◦ The computer BIOS and device drivers provide basic functionality
to operate and control the hardware connected to or built into the
computer.
◦ Basic Input/Output System(BIOS) is a de facto standard defining a
firmware interface.
◦ BIOS is built into the computer and is the first code run by the
computer when it is switched on.
◦ The key role of BIOS is to load and start the operating system.

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 13


Classification of Computer Software
Computer BIOS and Device Drivers
◦ When the computer starts, the first function that BIOS performs is
to initialize and identify system devices such as the video display
card, keyboard and mouse, hard disk, CD/DVD drive, and other
hardware.
◦ The code in the BIOS chip runs a series of tests called POST (Power
On Self Test) to ensure that the system devices are working
correctly.

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 14


Classification of Computer Software
Computer BIOS and Device Drivers
BIOS then locates software held on a peripheral device such as a
hard disk or a CD, and loads and executes that software, giving it
control of the computer. This process is known as Booting

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 15


Classification of Computer Software
Computer BIOS and Device Drivers
BIOS is stored on a ROM chip built into
the system and has a user interface like
that of a menu shown in Figure.

It can be accessed by pressing a certain


key on the keyboard when the
computer starts.

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 16


Classification of Computer Software
Computer BIOS and Device Drivers
The BIOS menu can enable the user to :
◦ Configure hardware
◦ Set the system clock
◦ Enable or disable system components
◦ Select which devices are eligible to be a potential boot device
Set various password prompts

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 17


Classification of Computer Software
Computer BIOS and Device Drivers
To summarize, BIOS performs the following functions:
◦ Initializes the system hardware
◦ Initializes system registers
◦ Initializes power management system
◦ Tests RAM
◦ Tests all the serial and parallel ports
◦ Initializes CD/DVD drive and hard disk controllers
◦ Displays system summary information

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 18


Classification of Computer Software
Operating System
◦ The primary goal of an operating system is to make the computer
system convenient and efficient to use.
◦ An operating system offers generic services to support user
applications

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 19


Classification of Computer Software
Operating System
◦ From users’ point of view the primary consideration is always the
convenience.
◦ Users should find it easy to launch an application and work on it.
◦ It is the human–computer interface which helps to identify and
launch an application.
Example:
◦ We use icons which give us clues about applications. We have a different icon for launching a web browser, e-mail
application, or even a document preparation application.
◦ If we examine the programs that help us in using input devices like keyboard/mouse, all the complex details of the
character reading programs are hidden from users. We as users simply press buttons to perform the input
operation regardless of the complexity of the details involved.

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 20


Classification of Computer Software
Operating System
◦ An operating system ensures that the system resources (such as
CPU, memory, I/O devices) are utilized efficiently.
◦ Operating system should have a control policy and algorithm to
allocate the system resources.
Example:
◦ There may be many service requests on a web server and each user request needs to be serviced.
◦ There may be many programs residing in the main memory.
◦ Therefore, the system needs to determine which programs are currently being executed and which programs
need to wait for some I/O operation. This information is necessary because the programs that need to wait can be
suspended temporarily from engaging the processor.
◦ Hence, it is important for an operating system to have a control policy and algorithm to allocate the system
resources.

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 21


Classification of Computer Software
Utility Software
◦ Utility software is used to analyse, configure, optimize, and
maintain the computer system.
◦ Utility programs may be requested by application programs
during their execution for multiple purposes.
Some of them are as follow:
◦ Disk defragmenters ◦ Disk compression utilities ◦ Cryptographic utilities
◦ Disk checkers ◦ File Managers ◦ Launcher applications
◦ Disk space analysers ◦ System profilers ◦ Registry cleaners
◦ Disk partitions utilities ◦ Anti-virus ◦ Network utilities
◦ Backup utilities ◦ Data compression ◦ Command line interface

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 22


Classification of Computer Software
Utility Software
Disk defragmenters: Used to detect computer files whose contents
are broken across several locations on the hard disk, and move the
fragments to one location in order to increase efficiency.

Disk checkers: Used to scan the contents of a hard disk to find files
or areas that are either corrupted in some way, or were not
correctly saved, and eliminate them in order to make the hard drive
operate more efficiently

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 23


Classification of Computer Software
Utility Software
Disk cleaners : Used to locate files that are either not required for
computer operation, or take up considerable amounts of space.
Disk cleaners help users to decide what to delete when their hard
disk is full.

Disk space analysers: Used for visualizing the disk space usage by
getting the size for each folder (including subfolders) and files in a
folder or drive

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 24


Classification of Computer Software
Utility Software
Disk partitions utilities: Used to divide an individual drive into multiple
logical drives, each with its own file system.
Each partition is then treated as an individual drive.

Backup utilities: Used to make a copy of all information stored on a disk.


In case a disk failure occurs, backup utilities can be used to restore the
entire disk.
Even if a file gets deleted accidentally, the backup utility can be used to
restore the deleted file
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 25
Classification of Computer Software
Utility Software
Disk compression utilities : Used to enhance the capacity of the disk
by compressing/decompressing the contents of a disk.

File managers : Used to provide a convenient method of performing


routine data management tasks such as deleting, renaming,
cataloguing, moving, copying, merging, generating, and modifying
data sets.

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 26


Classification of Computer Software
Utility Software
System profilers : Used to provide detailed information about the
software installed and hardware attached to the computer.

Anti-virus utilities :Used to scan for computer viruses.

Data compression utilities : Used to output a file with reduced file


size.

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 27


Classification of Computer Software
Utility Software
Cryptographic utilities :Used to encrypt and decrypt files.

Launcher applications :Used as a convenient access point for


application software.

Registry cleaners :Used to clean and optimize the Windows


operating system registry by deleting the old registry keys that are
no longer in use

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 28


Classification of Computer Software
Utility Software
Network utilities: Used to analyse the computer’s network
connectivity, configure network settings, check data transfer, or log
events.

Command line interface (CLI) and Graphical user interface (GUI):


Used to make changes to the operating system

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 29


Classification of Computer Software
◦ A program written in a high-level language can be executed in
any of the two ways.
◦ First by compiling the program
◦ Second, to pass the program through an interpreter

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 30


Classification of Computer Software
Compiler
• Compiler is a special type of program that transforms the Source
code written in a programming language into machine language
comprising just two digits, 1s and 0s (the target language).
• The resultant code in 1s and 0s is known as the Object code.
• The object code is the one which will be used to create an
executable program.

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 31


Classification of Computer Software
Compiler
• If the source code contains errors then the compiler will not be
able to perform its intended task.
Syntax Error
• Errors resulting from the code not conforming to the syntax of the
programming language.
• Syntax errors may be spelling mistakes, typing mistakes, etc.
Logical Error
• Errors that occurs when the program does not function accurately .
• Logical errors are much harder to locate and correct.

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 32


Classification of Computer Software
Interpreter
◦ Interpreter translates the instructions written in high-level
programming language instructions into an intermediate form,
which it then executes.
◦ This clearly means that the interpreter interprets the source
code line by line.

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 33


Classification of Computer Software
Interpreter
◦ Usually, a compiled program executes faster than an interpreted
program.
◦ However, the big advantage of an interpreted program is that it
does not need to go through the compilation stage during which
machine instructions are generated.
◦ This process can be time consuming if the program is long.
◦ Moreover, the interpreter can immediately execute high-level
programs.

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 34


Classification of Computer Software
Interpreter
◦ Usually, a compiled program executes faster than an interpreted
program.
◦ However, the big advantage of an interpreted program is that it
does not need to go through the compilation stage during which
machine instructions are generated.
◦ This process can be time consuming if the program is long.
◦ Moreover, the interpreter can immediately execute high-level
programs.

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 35


Classification of Computer Software
Linker
• It is a program that combines object modules to form an executable
program.
• Generally, in case of a large program, the programmers prefer to break a
code into smaller modules as this simplifies the programming task.
• Eventually, when the source code of all the modules has been converted
into object code, we need to put all the modules together. This is the job
of the linker.
• Usually, the compiler automatically invokes the linker as the last step in
compiling a program.

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 36


Classification of Computer Software
Loader
• It is a special type of program that copies programs from a
storage device to main memory, where they can be executed.
• Functionality of a loader is generally hidden from the
programmer.
• As a programmer, it suffices to learn that the task of a loader is
to bring the program and all its related files into the main
memory from where it can be executed by the CPU.

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 37


Classification of Computer Software
Computer software can be broadly classified into two groups:
◦ System software
◦ Application software

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 38


Classification of Computer Software
Application software
◦ Application software is a type of computer software that employs
the capabilities of a computer directly to perform a user-defined
task.
◦ Application software is designed to solve a particular problem for
users.
◦ Example: Spreadsheets, database systems, desktop publishing
systems, program development software, games, web browsers.

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 39


Classification of Computer Software
Application software
Analogy to understand application software
◦ Hardware depict the relationship of an electric light bulb (an
application) to an electric power generation plant (a system) that
depicts the software.
◦ The power plant merely generates electricity which is not by itself
of any real use until harnessed to an application like the electric
light that performs a service which actually benefits users.

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 40


Classification of Computer Software
Application software
• Multiple applications bundled together as a package are
sometimes referred to as an Application suite.
• Typical examples of software applications
◦ Word processors
◦ Spreadsheets
◦ Media players
◦ Education software
◦ CAD
◦ CAM
◦ Data communication software
◦ Statistical and Operational research software.
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 41
Programming Languages
• A programming language is a language specifically designed to
express computations that can be performed by the computer.
• Programming languages are used to create programs that control
the behaviour of a system, to express algorithms, or as a mode of
human–computer communication.
• Programming languages have a vocabulary of syntax and semantics
for instructing a computer to perform specific tasks.

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 42


Programming Languages
• High-level programming languages are BASIC, C, C++, COBOL,
FORTRAN, Ada and Pascal.
• Each of these languages has a unique set of keywords (words that
it understands) and a special syntax for organizing program
instructions.
• Program written in any programming language has to be converted
into machine language.
• There are two ways to do this:
• Compile the program
• Interpret the program

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 43


Programming Languages
• High-level programming languages are easy for humans to read
and understand, the computer actually understands the machine
language that consists of numbers only.
• Each type of CPU has its own unique machine language.
• In between the machine languages and high-level languages, there
is another type of language known as assembly language.
• Assembly languages are similar to machine languages, but they are
much easier to program because they allow a programmer to
substitute names for numbers.

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 44


Programming Languages
The question of which language is the best depends on the
following factors:
• The type of computer on which the program has to be executed
• The type of program
• The expertise of the programmer

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 45


Programming Languages
Example:
• FORTRAN is a particularly good language for processing numerical
data, but it does not lend itself very well to organizing large
programs.
• Pascal can be used for writing well-structured and readable
programs, but it is not as flexible as the C programming language.
• C++ goes one step ahead of C by incorporating powerful object-
oriented features, but it is complex and difficult to learn

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 46


Generation of Programming Languages
The four generations of programming languages include:
❖Machine language
❖Assembly language
❖High-level language
❖Very high level language

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 47


First Generation: Machine Language
➢Used in first stored program on computer systems.
➢Lowest level of programming language.
➢Only language that the computer understands.
➢All the commands and data values are expressed using ones and zeros corresponding to the
‘on’ and ‘off’ electrical States in a computer
➢All instructions memory locations numbers and characters are represented in strings of ones
and zeros. As shown below.

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 48


First Generation: Machine Language
➢Binary numbers are represented in octal or hexadecimal, still are not easy for
humans to read, write or debug advantage - code can run very fast and
efficiently since it is directly executed by the CPU
➢Advantage - code can run very fast and efficiently since it is directly executed
by the CPU
➢Disadvantage - difficult to learn and far more difficult to edit if errors occur
➢To add new instructions at some memory location, all the instructions after the
insertion point has to be moved down.
➢Not portable across systems and needs to be rewritten for each computer.

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 49


Second Generation – Assembly Language
➢Symbolic programming languages that use symbolic notation to represent machine-language
instructions.

➢Assembly language is also called low-level language.

➢It uses symbolic codes also known as mnemonic codes that are easy-to-remember
abbreviations, rather than numbers.

➢Examples of these codes include ADD for add, CMP for compare, MUL for multiply, etc.

➢Basically, an assembly language statement consists of a label, an operation code, and one or
more operands.

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 50


Second Generation – Assembly Language
➢Labels are used to identify and reference instructions in the program. The operation code (opcode) is a
mnemonic that specifies the operation that has to be performed such as move, add, subtract, or compare.

➢The operand specifies the register or the location in main memory where the data to be processed is
located.

➢The statement or instruction in the assembly language will vary from

➢machine to another - not designed to be machine independent and hence is not portable.

➢The code written is efficient in terms of execution time and main memory usage.

➢Programs written in assembly language need a translator often known as assembler to convert them into
machine language.
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 51
Second Generation – Assembly Language
➢This is because the computer will understand only the language of 1s and 0s and will not
understand mnemonics like ADD and SUB.

➢The following instructions are a part of assembly language code to illustrate addition of two
numbers:

➢MOV AX,4 Stores value 4 in the AX register of CPU

➢MOV BX,6 Stores value 6 in the BX register of CPU

➢ADD AX,BX Adds the contents of AX and BX registers. Stores the result in AX register

➢ Programmers still use assembly language to write parts of applications where speed of
execution is critical, such as video games.
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 52
Third Generation Programming Languages
➢Third Generation Programming Languages are not closely related to the internal architecture of the
computer and is therefore often referred to as high-level languages.

➢A statement written in a high-level programming language will expand into several machine language
instructions.

➢Programming is easier, efficient, and less prone to errors.

➢Third Generation Programming Languages include languages such as FORTRAN (FORmula TRANslator) and
COBOL (COmmon Business Oriented Language)

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 53


Third Generation Programming Languages
➢A few high-level languages like C and FORTRAN combine some of the flexibility of assembly language with
the power of high-level languages.

➢Some high-level languages were designed to serve a specific purpose (such as controlling industrial robots
or creating graphics), other languages were flexible and considered to be general-purpose languages.

➢Most of the programmers preferred to use general-purpose high-level languages like BASIC (Beginners’ All-
purpose Symbolic Instruction Code), FORTRAN, PASCAL, COBOL, C++, or Java to write the code for their
applications.

➢A translator is needed to translate the instructions written in high-level language into computer-
executable machine language.

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 54


Third Generation Programming Languages
➢Such translators are commonly known as interpreters and compilers. Each high-level language has many
compilers.

➢For example, the machine language generated by one computer’s C compiler is not the same as the
machine language of some other computer.

➢Therefore, it is necessary to have a C compiler for each type of computer on which the C program has to
be executed.

➢The programs written in such languages are portable between machines. For example, a program written
in standard C can be compiled and executed on any computer that has a standard C compiler.

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 55


Fourth Generation very High-Level Languages
➢Fourth generation programming languages (4GLs) are basically non-procedural.

➢When writing code using a procedural language, the programmer has to tell
the computer how a task is done—add this, compare that, do this if the
condition is true, and so on, in a very specific step-by-step manner.

➢In striking contrast, while using a non-procedural language the programmers


define only what they want the computer to do, without supplying all the details
of how it has to be done.

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 56


Fourth Generation very High-Level Languages
There is no standard rule that defines what a 4GL is but certain characteristics of
such languages include:
➢ the code comprising instructions are written in English-like sentences;

➢ they are non-procedural, so users concentrate on ‘what’ instead of the ‘how’ aspect of
the task;

➢ the code is easier to maintain;

➢ the code enhances the productivity of the programmers as they have to type fewer lines
of code to get something done.

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 57


Fourth Generation very High-Level Languages
➢A typical example of a 4GL is the query language which is used as a database user interface and hides the
specific details of the database from the user.

➢For example if a report has to be generated that displays the total number of students enrolled in each
class and in each semester.

➢Using a 4GL, the request would look similar to:

➢TABLE FILE ENROLLMENT SUM STUDENTS BY SEMESTER BY CLASS

➢The same code if written in C language or any other 3GL would require multiple lines of code to do the
same task.

➢The only downside of a 4GL is that it does not make efficient use of the machine’s resources.

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 58


Fifth Generation Programming Languages
➢Fifth generation programming languages (5GLs) are centred on solving problems using
constraints given to the program, rather than using an algorithm written by a programmer.

➢Most constraint-based and logic programming languages and some declarative languages form
a part of the fifth-generation languages. Widely used in artificial intelligence research.

➢Typical examples of 5GLs include Prolog, OPS5, and Mercury.

➢Another aspect of a 5GL is that it contains visual tools to help develop a program.

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 59


Fifth Generation Programming Languages
➢A good example of a fifth generation language is Visual Basic.

➢Generally, 5GLs were built upon Lisp, many originating on the Lisp machine,
such as ICAD. Then, there are many frame languages such as KL-ONE.

➢Software vendors across the globe currently claim that their software meets
the visual ‘programming’ requirements of the 5GL concept.

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 60


INTRODUCTION TO C

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 61


INTRODUCTION TO C
Introduction
Background
Characteristics of C
Uses of C

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 62


Introduction
➢C was developed in the early 1970s by Dennis Ritchie at Bell Laboratories

➢C was initially developed for writing system software

➢Today, C has become a popular language and various software programs are
written using this language.

➢Many other commonly used programming languages such as C++ and Java
are also based on C

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 63


Background
• ALGOL introduction in 1960s led the way for development of
structured programming concepts.
• In 1967, Martin Richards developed a language called Basic
Combined Programming Language(BPCL).
• In 1970, Ken Thompson developed a language called B.
• In 1972, Dennis Ritchie developed a language called C.
• In 1978, C was documented and popularized in the book “The
C Programming Language” by Brian W.Kernighan and Dennis
Ritchie. This book was so popular that language came to be
known as K & R C
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 64
Background
• In 1983, American National Standard Institute(ANSI)
started working on defining the standard for C. This
standard was approved in December 1989 and came to
be known as ANSI C.
• In 1990, the International Standards Organization (ISO)
adopted the ANSI standard. This version came to be
know as C89.
• In 1995, some minor changes were made to C89 and the
new modified version was known as C95.
• In 1999, some significant changes were made to C95
and the new modified version was known as C99.
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 65
Characteristics of C
C is a robust language with rich set of built-in functions and operators that can
be used to write complex programs.

It combines features of both assembly language and high-level languages,


making it best suited for writing software as well as business packages.

➢ A high level programming language

➢Small size. C has only 32 keywords. This makes it relatively easy to learn.

➢Makes extensive use of function calls

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 66


Characteristics of C
➢C is well suited for structured programming. In this programming approach –
users can think in terms of functions/modules. This facilitates to debug, test
and maintain program easily.

➢Unlike PASCAL it supports loose typing (as a character can be treated as an


integer and vice versa)

➢Stable language – ANSI C was created in 1983 and since then it has not been
revised.

➢Quick language – fast and efficient, executes in less time.

➢Facilitates low level (bitwise) programming


DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 67
Characteristics of C
➢Supports pointers to refer computer memory, array, structures and functions.

➢C is a core language. Other languages are based on C.

➢C is a portable language.

➢C is an extensible language – enables users to add their own functions to its


library

➢C is considered to be the second best language for any task while the first
best language depends on that particular task.

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 68


Uses of C
➢C language is primarily used for system programming. The portability, efficiency, the ability
to access specific hardware addresses and low runtime demand on system resources makes it
a good choice for implementing operating systems and embedded system applications.

➢C has been used to write compilers, libraries, and interpreters of other programming
languages.

➢For portability and convenience reasons, C is sometimes used as an intermediate language


by implementations of other languages. Example of compilers which use C this way are BitC,
Gambit, the Glasgow Haskell Compiler, Squeak, and Vala.

➢C is widely used to implement end-user applications

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 69


END

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 70

You might also like