Download as pdf or txt
Download as pdf or txt
You are on page 1of 48

CSIR12 - INTRODUCTION TO

COMPUTER PROGRAMMING

26-02-2024 1
Unit Objectives
• To learn the fundamentals of computers.
• To learn the problem solving techniques using algorithms &
procedures.

26-02-2024 2
Unit Outcome
• write algorithms for problems

26-02-2024 3
Syllabus – M 1
Introduction to computers – Computer Organization – Characteristics –
Hardware and Software – Modes of operation – Types of programming
languages – Developing a program. Algorithms – Characteristics –
Flowcharts.

26-02-2024 4
Introduction to Computers
• Computer is an advanced electronic device that takes raw data as
input from the user and processes these data under the control of set
of instructions (called program) and gives the result (output) and
saves output for the future use.
• A computer is a combination of hardware and software resources
which integrate together and provides various functionalities to the
user.
• Hardware are the physical components of a computer like the
processor, memory devices, monitor, keyboard etc. while software is
the set of programs or instructions that are required by the hardware
resources to perform various operations as per the requirement of
users.
26-02-2024 5
Introduction to Computers

26-02-2024 6
Introduction to Computers

26-02-2024 7
Introduction to Computers

26-02-2024 8
Introduction to Computers
• The first generation computers used vacuum tubes & machine
language was used for giving the instructions.
• These computers were large in size & their programming was difficult
task.
• The electricity consumption was very high. Some computers of this
generation are ENIAC, EDVAC, EDSAC & UNIVAC-1.
• In this generation, mainly batch processing operating system was
used.
• Punch cards, paper tape, and magnetic tape was used as input and
output devices.
• The computers in this generation used machine code as the
programming language.
26-02-2024 9
Introduction to Computers

cost

26-02-2024 10
Introduction to Computers
• In 2nd generation computers, vacuum tubes were replaced by
transistors. They required only 1/10 of power required by tubes.
• This generation computers generated less heat & were reliable. The
first operating system developed in this generation. IBM 1620, IBM
7094, CDC 1604 are the examples of this generations computers.
• Magnetic cores were used as the primary memory and magnetic tape
and magnetic disks as secondary storage devices.
• In this generation, assembly language and high-level programming
languages like FORTRAN, COBOL were used. The computers used
batch processing and multiprogramming operating system.
26-02-2024 11
Introduction to Computers

26-02-2024 12
Introduction to Computers
• The 3rd generation computers replaced transistors with Integrated circuit
known as chip. From Small scale integrated circuits which had 10
transistors per chip, technology developed to MSI circuits with 100
transistors per chip.
• These computers were smaller, faster & more reliable. High level languages
invented in this generation. The IC was invented by Jack Kilby.
• This development made computers smaller in size, reliable, and efficient. In
this generation remote processing, time-sharing, multiprogramming
operating system were used.
• High-level languages (FORTRAN-II TO IV, COBOL, PASCAL PL/1, BASIC,
ALGOL-68 etc.) were used during this generation. IBM-360 series,
Honeywell-6000 are some examples of computers in this generation.
26-02-2024 13
Introduction to Computers

26-02-2024 14
Introduction to Computers
• LSI & VLSI were used in fourth generation. As a result
microprocessors came into existence. The computers using this
technology known to be Micro Computer.
• High capacity hard disk were invented. There is great development
in data communication.
• Fourth generation computers became more powerful, compact,
reliable, and affordable. As a result, it gave rise to Personal
Computer (PC) revolution.
• In this generation, time sharing, real time networks, distributed
operating system were used. All the high-level languages like C,
C++, DBASE etc., were used in this generation.
26-02-2024 15
Introduction to Computers
• Fifth generation computing devices, based on artificial
intelligence, are still in development, though there are some
applications, such as voice recognition, that are being used today.
The use of parallel processing and superconductors is helping to
make artificial intelligence a reality. Quantum computation and
molecular and nanotechnology will radically change the face of
computers in years to come.
Some computer types of this generation are −
• Desktop
• Laptop
• Note Book
• Ultra Book
26-02-2024 16
Computer Organization - Functional Units of
Computers

26-02-2024 17
Computer Characteristics
• All digital computers, regardless of their size, are electronic
devices that can transmit, store, and manipulate information (Le.,
data).
• Several different types of data can be processed by a computer.
These include numeric data, character data (names, addresses,
etc.), graphic data (charts, drawings, photographs, etc.), and
sound (music, speech patterns, etc.).
• The two most common types, from the standpoint of a beginning
programmer, are numeric data and character data.

26-02-2024 18
Computer Characteristics
• Scientific and technical applications are concerned primarily with
numeric data, whereas business applications usually require
processing of both numeric and character data.
• To process a particular set of data, the computer must be given an
appropriate set of instructions called a program.
• These instructions are entered into the computer and then stored
in a portion of the computer’s memory.

26-02-2024 19
Computer Characteristics
• A stored program can be executed at any time.
1. A set of information, called the input data, will be entered into
the computer (from the keyboard, a floppy disk, etc.) and stored
in a portion of the computer’s memory.
2. The input data will be processed to produce certain desired
results, known as the output data.
3. The output data, and perhaps some of the input data, will be
printed onto a sheet of paper or displayed on a monitor (a
television receiver specially designed to display computer
output).
4. This three-step procedure can be repeated many times if
desired, thus causing a large quantity of data to be processed in
rapid sequence.
26-02-2024 20
Computer Characteristics
EXAMPLE 1: A computer has been programmed to calculate the
area of a circle using the formula a = ∏r^2, given a numeric value for
the radius r as input data.
The following steps are required.
1. Read the numeric value for the radius of the circle.
2. Calculate the value of the area using the above formula. This
value will be stored, along with the input data, in the computer’s
memory.
3. Print (display) the values of the radius and the corresponding
area.
4. stop.
Each of these steps will require one or more instructions in a
computer program.
26-02-2024 21
Hardware

26-02-2024 22
Memory
• Every piece of information stored within the computer’s memory
is encoded as some unique combination of zeros and ones. These
zeros and ones are called bits (binary digits). Each bit is
represented by an electronic device that is, in some sense, either
“off’ (zero) or “on” (one).
• 1 Byte = 8 bits, 1 Nibble = 4 bits
• 1 Kilo Byte = 1024 Byte= 2^10 Byte
• 1 Mega Byte = 1024 KB= 2^10 KB
• 1 Giga Byte = 1024 MB= 2^10 MB
• 1 Tera Byte = 1024 GB= 2^10 GB
• 1 Peta Byte =1024 TB= 2^10 TB
• 1 Exa Byte =1024 PB= 2^10 PB
• 1 Zetta Byte = 1024 EB= 2^10 EB
• 1 Yotta Byte = 1024 ZB= 2^10 ZB
26-02-2024 23
Memory

26-02-2024 24
Memory
• Primary memory is also known as Main memory or Internal memory. Examples: RAM,
ROM, Cache memory, PROM, EPROM, Registers, etc.

• Secondary memory is also known as External memory or Auxiliary memory used to store
data permanently for future use.
Examples: Hard Disk, Floppy Disk, Magnetic Tapes, etc.

26-02-2024 25
Software
• Computer is a general-purpose, problem-solving machine.
• To solve any computable problem, a computer must be capable of executing any
algorithm.
• We build some basic operations into the hardware’s processor and require any
algorithm to use them.
• The algorithms are converted to binary form and then loaded, with their data, into the
computer’s memory. The processor can then execute the algorithms’ instructions by
running the hardware’s more basic operations. Any programs that are stored in
memory so that they can be executed later are called software.
• A program stored in computer memory must be represented in binary digits, which is
also known as machine code.
• A loader takes a set of machine language instructions as input and loads them into the
appropriate memory locations. When the loader is finished, the machine language
program is ready to execute.
26-02-2024 26
Software Types
• System Software -programs that make the development, execution, and management
of other programs. Ex: Operating System (includes file system, UI)
• Application Software - program that is designed for a specific task, such as editing a
document or displaying a Web page. Applications include Web browsers, word
processors, spreadsheets, database managers, graphic design packages, music
production systems, and games.

26-02-2024 27
Modes of Operation
• There are two different ways that a large computer can be shared by
many different users. These are the batch mode and the interactive
mode.
• In batch processing, a number of jobs are entered into the computer,
stored internally, and then processed sequentially. (A job refers to a
computer program and its associated sets of input data.) After the job is
processed, the output, along with a listing of the computer program, is
printed on multiple sheets of paper by a high-speed printer.

26-02-2024 28
Modes of Operation
• Timesharing allows many different users to use a single computer
simultaneously. The host computer may be a mainframe, a
minicomputer or a large desktop computer.
• The various users communicate with the computer through their own
individual terminals. In a modern timesharing network, personal
computers are often used as timesharing terminals.
• Since the host computer operates much faster than a human sitting at a
terminal, the host computer can support many terminals at the same
time.
• Thus, each user will be unaware of the presence of any other users and
will seem to have the host computer at his or her own disposal.

26-02-2024 29
Modes of Operation
• Interactive computing is a type of computing environment that
originated with commercial timesharing systems and has been refined
by the widespread use of personal computers.
• In an interactive computing environment, the user and the computer
interact with each other during the computational session.
• Thus, the user may periodically be asked to provide certain information
that will determine what subsequent actions are to be taken by the
computer and vice versa.

26-02-2024 30
Programming Languages

• Computer hardware can execute only instructions that are written in binary form—
that is, in machine language.
• Writing a machine language program, however, would be an extremely tedious,
error-prone task.
• To ease the process of writing computer programs, computer scientists have
developed high-level programming languages for expressing algorithms. These
languages resemble English and allow the author to express algorithms in a form
that other people can understand.

26-02-2024 31
Programming Languages
• A programmer typically starts by writing high-level
language statements in a text editor.
• The programmer then runs another program called a
translator to convert the high-level program code into
executable code. Because it is possible for a programmer
to make grammatical mistakes even when writing high-
level code, the translator checks for syntax errors before
it completes the translation process. If it detects any of
these errors, the translator alerts the programmer via
error messages. The programmer then has to revise the
program. If the translation process succeeds without a
syntax error, the program can be executed by the run-
time system.
• The run-time system might execute the program
directly on the hardware or run yet another program
called an interpreter or virtual machine to execute the
26-02-2024 32
Types of Programming Languages

26-02-2024 33
Types of Programming Languages
• Low level Language – natural dialect, set of instructions to control the
internal circuit of computer, difficult and each machine will have their
own instruction set.
• Middle Level Language - use predefined words called mnemonics.
Binary code instructions in low-level language are replaced with
mnemonics and operands in middle-level language. But the computer
cannot understand mnemonics, so we use a translator
called Assembler to translate mnemonics into machine language.
• High Level Language – Compatible wit human languages, (general
purpose –C, special purpose –LISP), Simple, uniform, portable.

26-02-2024 34
Types of Programming Languages
• Assembler is a translator which takes assembly code as input and produces
machine code as output. That means, the computer cannot understand middle-
level language, so it needs to be translated into a low-level language to make it
understandable by the computer. Assembler is used to translate middle-level
language into low-level language.
• Compilers translate the entire program into machine language before executing
any of the instructions. Interpreters, on the other hand, proceed through a
program by translating and then executing single instructions or small groups of
instructions.
• A compiler or interpreter is itself a computer program. It accepts a program
written in a high-level language (e.g., C) as input, and generates a corresponding
machine-language program as output.
• The original high-level program is called the source program, and the resulting
machine-language program is called the object program. Every computer must
have its own compiler or interpreter for a particular high-level language.
26-02-2024 35
Algorithms
• In computer programming terms, an algorithm is a set of well-defined
instructions to solve a particular problem. It takes a set of input(s)
and produces the desired output.
• Example - An algorithm to add two numbers:
• Take two number inputs
• Add numbers using the + operator
• Display the result

26-02-2024 36
Qualities of a Good Algorithm
• An algorithm consists of a finite number of instructions.
• Each individual instruction in an algorithm is well defined. This means that
the action described by the instruction can be performed effectively or be
executed by a computing agent. For example, any computing agent capable
of arithmetic can compute the difference between two digits. So an
algorithmic step that says “compute the difference between two digits”
would be well defined. On the other hand, a step that says “divide a number
by 0” is not well defined, because no computing agent could carry it out.
• An algorithm describes a process that eventually halts after arriving at a
solution to a problem. For example, the process of subtraction halts after the
computing agent writes down the difference between the two digits in the
leftmost column of digits.
• An algorithm solves a general class of problems. For example, an algorithm
that describes how to make change should work for any two amounts of
money whose difference is greater than or equal to $0.00.
26-02-2024 37
Qualities of a Good Algorithm

26-02-2024 38
Algorithm Example 1

26-02-2024 39
Algorithm Example 2

26-02-2024 40
Algorithm Example 3

26-02-2024 41
Algorithm Example 4

26-02-2024 42
Flowchart
• Flowchart is a diagrammatic representation of sequence of logical
steps of a program. Flowcharts use simple geometric shapes to
depict processes and arrows to show relationships and process/data
flow.
• Benefits of Developing Flowcharts
• It helps to clarify complex processes.
• It identifies steps that do not add value to the internal or external customer,
including delays; needless storage and transportation; unnecessary work,
duplication, and added expense; breakdowns in communication.
• It helps team members gain a shared understanding of the process and use
this knowledge to collect data, identify problems, focus discussions, and
identify resources.
• It serves as a basis for designing new processes.

26-02-2024 43
Flowchart symbols

26-02-2024 44
Flowchart Guidelines
• Flowchart can have only one start and one stop symbol
• On-page connectors are referenced using numbers
• Off-page connectors are referenced using alphabets
• General flow of processes is top to bottom or left to right
• Arrows should not cross each other

26-02-2024 45
Flowchart Example 1

26-02-2024 46
Flowchart Example 2

26-02-2024 47
Flowchart Example 3

26-02-2024 48

You might also like