Chapter-1 COMPUTER PROGRAMING PRE.
Chapter-1 COMPUTER PROGRAMING PRE.
Computer Programming
1
Out line
1.1. What is computer programming
1.2. Reasons to study programming
1.3. Types and usage of computer languages
1.4. Programming paradigms
1.4.1. Procedural programming
1.4.2. Functional programming
1.4.3. Object-oriented Programming
2
Computer Systems
Computer
Software Component
Hardware Component
3
Hardware Components
Hardware of a computer system can be referred to as anything which we can touch and
feel.
Include :
Input device
Output device
Secondary storage
4
Software Components
Computer software refers to a programming code, that is executed on computer hardware that
facilitates the completion of tasks by a computer.
It is a set of instructions.
Computer software is divided into two broad categories:
System Software
2 Application Software
System Software: is responsible for controlling, integrating, and managing the individual
hardware components of a computer system.
Like operating system, device drivers, and utility programs..
5
Software Components
Application Software:
Is used to accomplish specific tasks other than just running the computer system
Consists of programs designed to make users more productive and/or assist them with personal
tasks.
Simply applications, are often called productivity programs or end-user programs because they
enable the user to complete tasks, such as creating documents, spreadsheets, databases, and
publications, doing online research, sending emails, designing graphics, running businesses, and
even playing games.
Examples: MS-office, web browsers, database software, photoshop, etc.
6
Computer Programming
Computer Programming:
Is the process of creating a set of instructions that tell a computer how to perform a
task.
Is the process of creating computer software using a programming Language.
It involves knowing the statements used in a programming language and how to
choose and arrange those statements so that the computer performs the tasks logically.
The process of writing a computer program is called programming.
Programs are written by people known as Programmers
7
Why to learn programming
To get money
05
8
Computer Languages
Low-Level Language:
• Low-level languages are the basic computer instructions or better known as machine codes.
• A computer cannot understand any instruction given to it by the user in English or any other
high-level language.
These low-level languages are very easily understandable by the machine.
10
Computer Languages
There are two types of low-level computer language:
Machine Languages
Assembly Languages
Machine Languages: This is one of the most basic low-level languages.
it is machine dependent- it means that a particular machine language can be used on only
one type of computer.
Machine language is a low-level language that writes programs using the machine code of 1s
and 0s (binary number),which is directly understood by the computer.
E.g. Machine language code might look like this:
000101101010
11
Computer Languages
Advantages:
It makes fast and efficient use of the computer
It doesn't requires translator to translate the code i.e. directly understood by the computer
12
Computer Languages
Assembly Languages:
Is a low-level symbolic language written using symbolic(abbreviated sets of letters)
or short codes that suggest their meaning.
Assembly language uses mnemonics or symbolic instructions in place of a sequence
of 0s and 1s.
It was developed to overcome some of the many inconveniences of machine
language.
As an example, we can consider that to add registers A and B in a particular
computer, assembly language uses the mnemonic ‘ADD B’.
13
Computer Languages
High-Level Languages:
It is not machining dependent –this means it can be used on different machine
with little modifications.
It easier to learn and understand, because it is like English/ near to natural
language.
It uses variables and objects, Boolean expressions, functions, loops, threads,…
Require less time to write and easier to debug errors.
Is designed for developing user-friendly programs and websites.
Some examples are: C, C++, FORTRAN, COBOL, Java , Python ,JavaScript, PHP…..
int main()
{
cout << "Hello World!";
return 0; } 14
Programming Paradigms
Paradigm can also be termed as method to solve some problem or do some task.
Programming paradigm is an approach to solve problem using some language
or
Also we can say, it is a method to solve a problem using tools and techniques
that are available to us by following some approach.
It is all about the writing style and organizing the program code in a specific
way.
A programming paradigm represents the fundamental style or methodology of
computer programming ,that define how computer programs are organized and
executed.
They play a crucial role in shaping the design and the development of software
15
systems/program.
Programming Paradigms
Types of programming paradigms:
There are several types of programming paradigms, including procedural, object-
oriented, and functional.
Each of these paradigms has its own set of concepts, tools, and techniques, and
choosing the right one is essential to the success of a project, as it affects the
maintainability, scalability, and performance(efficiency) of the code.
Procedural Programming
18
Functional Programming:
Functional programming is a way of thinking about software construction by creating
pure functions.
The key principle of this paradigms is the execution of series of mathematical functions.
The central model for the abstraction is the function which are meant for some specific
computation and not the data structure.
Functional programming method focuses on results, not the process.
Functional languages emphasize expressions and declarations rather than the execution of
statements.
Examples of functional programming
JS, Lisp, SQL, Scala, Haskell, etc.
19
Cont….
• There are lots of programming languages that are known but all of them need to follow
some strategy when they are implemented this methodology/strategy is a paradigm.
• Each language has its own unique style and is often designed to support a certain
programming paradigm.
20
Computer Language Translators
A translator is a programming language processor that converts a computer program from one
language to another.
Language translators are system programs that convert assembly language and high-level
language to machine language for execution, because computers work in machine code only.
Programs must be translated into machine/Object codes before execution.
21
Computer Language Translators
Types of Language Translator:
Assembler
Translators Compiler
Interpreter
22
Cont..
Assembler
An assembler translates assembly language into machine code.
Assembly language contains machine op-code mnemonics so that assemblers translate from
mnemonics to direct instruction in a 1:1 relation.
Compiler
A compiler is a computer program that transforms the entire source code written in a high-
level language into object code for execution.
is a language translator program that converts code written in a human-readable language, such
as high-level language, to a low-level computer language, such as assembly language, machine
code, or object code, and then produces an executable program.
23
Cont..
Interpreter
An interpreter is a computer program that directly executes a high level programming language
one line at a time to run each time the source code is run, because no object code is generated.
It converts the program one at a time and reports errors detected at once while doing the
conversion.
It directly executes the operations specified in the source program when the input is given by
the user.
24
h a n k
T
y o u
25