DCP- 01
Computer
• A computer is an automatic, electronic and programmable device that can instruct hardware to carry out arbitrary sequences of arithmetic, logical and other operations in order to convert given input into desired output. It has ability to store, retrieve and process data. It usually consists of input, output, storage, CPU (arithmetic logic unit (ALU) and control unit (CU).
Basic Functions of Computer
Components of a Computer
Computer Hardware
• Physical components of a computer, such as CPU, Memory, Input and Output devices, Auxiliary storage devices.
• The hardware components include devices that perform the functions of accepting input, processing, data storage and generating output.
• Hardware is directed by the software to execute any instruction.
Central Processing Unit (CPU)
Control Unit
• This unit controls the operations of all parts of the computer but does not carry out any actual data processing operations.
• It is responsible for controlling the transfer of data and instructions among other units of a computer.
• It obtains the instructions from the memory, interprets them, and directs the operation of the computer.
• It communicates with Input / Output devices for transfer of data or results from storage.
Arithmetic/logic unit (ALU):
• Arithmetic operations: It performs arithmetic operations like addition, subtraction, multiplication, and division. All complex operations are done by making repetitive use of the above operations.
• Logic Operations: It also performs logical functions like comparing, selecting, and merging of data.
Input Device
• In computing, an input device is hardware equipment used to accept data and control signals from a user/device.
● This unit contains devices with the help of which we enter data into the computer.
● This unit creates a link between the user and the computer.
● The input devices translate the information into a form understandable by the computer
Input Devices
• Keyboard
• Mouse
• Joy Stick
• Light pen
• Digitizer or Graphic Tablet
• Track Ball
• Scanner
• Microphone
• Magnetic Ink Card Reader (MICR)
• Optical Character Reader (OCR)
• Bar Code Reader
• Optical Mark Reader (OMR)
Input Devices
Output Devices
● An output device consists of devices with the help of which we get the information from the computer.
● This unit is a link between the computer and the users.
● Output devices translate the computer's output into a form understandable by the users.
● Monitor
● Printer
Output Devices
Memory Unit
● Computer memory is any physical device capable of storing information temporarily or permanently.
● Primary memory
● Secondary memory
Primary memory
● Every computer has a temporary storage built into the computer hardware
● It stores instructions and data of a program mainly when the program is being executed by the CPU.
● This temporary storage is known as main memory, primary storage, or simply memory
Random Access Memory (RAM)
● Primary storage of a computer is often referred to as RAM because of its random access
capability
● RAM chips are volatile memory
● A computer‟s motherboard is designed in a manner that the memory capacity can be enhanced by adding more memory chips
Read Only Memory (ROM)
● ROM a non-volatile memory chip
● Data stored in a ROM can only be read and used – they cannot be changed
● ROMs are mainly used to store programs and data, which do not change and are frequently used. For example, system boot program
Types of ROMs
● Manufacturer-programmed- Data is burnt by the manufacturer of the electronic equipment in which it is used.
● User-programmed/programmable (PROM)- The user can load and store “read-only” programs and data in it.
● Erasable PROM (EPROM)- The user can erase information stored in it and the chip can be reprogrammed to store new information
● Ultra Violet EPROM (UVEPROM)- A type of EPROM chip in which the stored information is erased by exposing the chip for some time to ultra-violet light
● Electrically EPROM (EEPROM) or Flash memory- A type of EPROM chip in which the stored information is erased by using high voltage electric pulses
Cache Memory
● It is commonly used for minimizing the memory-processor speed mismatch.
● It is an extremely fast, small memory between CPU and main memory whose access time is closer to the processing speed of the CPU.
● It is used to temporarily store very active data and instructions during processing
Secondary Memory
● Used in a computer system to overcome the limitations of primary storage
● Has virtually unlimited capacity because the cost of storage is very low
● Has an operating speed far slower than that of the primary storage
● Used to store large volumes of data on a permanent basis
● Also known as auxiliary memory
Secondary Memory
Software
• Software is a set of programs, designed to perform a well-defined function.
• A program is a sequence of instructions written to solve a particular problem.
• There are two types of software -
• System Software
• Application Software
System Software
• The system software is a collection of programs designed to operate, control, and extend the processing capabilities of the computer itself.
• System software is generally prepared by the computer manufacturers.
• These software products comprise of programs written in low-level languages, which interact with the hardware at a very basic level.
System Software
• System software serves as the interface between the hardware and the end users.
• Some examples of system software are Operating Systems, Compilers etc.
Features of a system software
• Close to the system
• Fast in speed
• Difficult to design
• Difficult to understand
• Less interactive
• Difficult to manipulate
• Generally written in low-level language
Application software
• Application software products are designed to satisfy a particular need of a particular environment.
• All software applications prepared in the computer lab can come under the category of Application software.
• Application software may consist of a single program, or may also consist of a collection of programs, often called a software package, which work
together to accomplish a task.
Application software
• Application software may consist of a single program, or may also consist of a collection of programs, often called a software package, which work together to accomplish a task.
Features of an application software
• Close to the user
• Easy to design
• More interactive
• Slow in speed
• Generally written in high-level language
• Easy to understand
• Easy to manipulate and use
• Bigger in size and requires large storage space
Utility Programs
• A system software designed to help analyse, configure, optimize
or maintain a computer. It is used to support the computer
infrastructure in contrast to application software, which is
aimed at directly performing tasks that benefit ordinary users.
Utility Programs
1. Hardware Utilities: Hardware utilities can check the status of all parts of the PC, including hard disks, memory, modems, speakers and printers.
2. Security utilities: These software can constantly monitor and protect the computer. Anti virus and anti spyware software comes in this category.
3. File-Compression Utilities: These utilities can reduce the amount of disk space required to store a file or reduce the time it takes to transfer a file over the internet. Zip file, MP3 files comes in this category.
Applications of Computer/IT
Applications of Computer/IT
Applications of Computer/IT
Applications of Computer/IT
Applications of Computer/IT
History and Evolution of computers
• Charles Babbage, originated the concept of a programmable computer.
• he invented the first mechanical computer in the early 19th century called difference engine.
• in 1833, he designed more general design called Analytical Engine, was possible. The input of programs and data was to be provided to the
machine via punched cards.
• By 1938 the United States Navy developed an electromechanical analog computer.
• Early digital computers were electromechanical which used vacuum tubes.
History and Evolution of computers
• Compared to vacuum tubes, transistors have many advantages: they are smaller, and require less power than vacuum tubes, so give off less heat.
• The next great advance in computing power came with the advent of the integrated circuit.
• With the continued miniaturization of computing resources, and advancements in portable battery life, portable computers grew in popularity in the 2000s, leading to the development
of smartphones and tablets.
Generation of computers
First Generation
• The period of first generation: 1940-1959. Vacuum tube based.
• used vacuum tubes for circuitry and magnetic drums for memory.
• relied on machine language.
• Input was based on punched cards and paper tape, and output was displayed on printouts.
Generation of computers
Second Generation
• The period of second generation: 1959-1965. Transistor based.
• moved from cryptic binary machine language to symbolic, or assembly, languages.
• High-level programming languages were also being developed at this time, such as early versions of COBOL and FORTRAN.
• still relied on punched cards for input and printouts for output.
Generation of computers
Third Generation
• The period of third generation: 1965-1971. Integrated Circuit based.
• Instead of punched cards and printouts, users interacted with third
generation computers through keyboards and monitors and interfaced with an operating system.
Generation of computers
Fourth Generation
• The period of fourth generation: 1971-1980. VLSI(Very-large-scale integration) microprocessor based.
• The microprocessor brought the fourth generation of computers, as thousands of integrated circuits were built onto a single silicon chip
• Computers could be linked together to form networks, which eventually led to the development of the Internet.
• Fourth generation computers also saw the development of GUIs, the mouse.
Generation of computers
Fifth Generation
• The period of fifth generation: 1980-onwards. ULSI microprocessor based.
• used ULSI (Ultra Large Scale Integration) technology, resulting in the production of microprocessor chips having ten million electronic
components.
• Artificial intelligence and parallel processing are the primary characteristics of this generation.
Types of Computer
• Computers can be generally classified by size and power as follows, though there is considerable overlap:
• Personal computer: A small, single-user computer based on a microprocessor.
• Workstation: A powerful, single-user computer. A workstation is like a personal
computer, but it has a more powerful microprocessor and, in general, a higher-quality monitor.
• Minicomputer: A multi-user computer capable of supporting up to hundreds of users simultaneously.
• Mainframe: A powerful multi-user computer capable of supporting many hundreds or thousands of users simultaneously.
• Supercomputer: An extremely fast computer that can perform hundreds of millions of instructions per second.
Number System
• A number system is a mathematical notation for representing numbers of a given set, using digits or other symbols in a consistent manner.
• The number system can be seen as the context that allows the symbols "11" to be interpreted as the binary symbol for three, the decimal symbol
for eleven,....
• The number system consists of
Base
Set of digits (From 0 to Base-1)
Representation for a set of numbers (e.g. all integers)
Unique representation to every number in the set
45
Types of Number System
• Non-Positional number system
• Positional number system
46
Non-Positional Number System
• Symbol represents the value regardless of its position.
• Difficult to perform arithmetic operation.
• For example:-
I, II, III, IV, V, VI, VII, VIII, IX, X
XI,XII, XIII, XIV, XV, XVI, XVII, XVIII, XIX, XX
47
Positional Number System
• Symbols (Digits) represent different values depending upon the position.
• The values of each digit is determined by:-
• Digit itself
• Position of the digit
• Base of the number system
48 6
Continuing with our example…
642 in base 10 positional notation is:
6 x 10
2= 6 x 100 = 600 + 4 x 10
1= 4 x 10 = 40
+ 2 x 10º = 2 x 1 = 2 = 642 in base 10
This number is in base 10
The power indicates the position of
the number
Positional Number System
49
Decimal Number System
The base is equal to 10
Uses 10 different symbols.
For example:
(2*1000) + (5*100) + (8*10) + (6*1)
=2000 + 500 + 80 + 6
=2586
50
Binary Number System
• Binary digit 0 or 1
• The base is 2.
• Each position represents a power of the base 2.
Example:-Conversion from 00111101 to decimal is-
51
Conversion of decimal representation to binary
Divide decimal number to base 2 and Take remainders in reverse order. Example : Convert 3610 to binary number
(36)10 = (100100)2
2 36 2 18
2 9
2 4
2 2
2 1
0
Remainder 0
0 1 0 0 1
Least Significant Bit (LSB)
Most significant Bit (MSB)
52
24 23 22 21 20
16 8 4 2 1
1 1 0 1 0
1*16
+1*8
+0*4
+1*2
+0*1
= 16 + 8 + 0 + 2 + 0
= 26
Conversion of binary representation to decimal
• Covert (11010)
2to decimal
53
Octal Number System
The base is 8
The digits are 0-7
Each position represents a power of the base 8.
For example:- decimal equivalent to the octal number 421 is 273
54
Converting Decimal to Octal
(1988)
10= (?)
8(1988)
10= (3 7 0 4)
88 1988 Remainder
8 248 4
8 31 0
8 3 7
0 3
55
(642)
8= (?)
106 x 8
2= 6 x 64 = 384 + 4 x 8
1= 4 x 8 = 32 + 2 x 8º = 2 x 1 = 2
Sum = (418)
1011
Converting Octal to Decimal
56
Hexadecimal Number System
The base is 16
digit symbols in base 16 are 0,1,2,3,4,5,6,7,8,9,
A,B,C,D,E,F
Each position represents a
power of the base 2.
57 21
Converting Decimal to Hexadecimal
58
(DEF)
16= (?)
10D x 16
2= 13 x 256 = 3328 + E x 16
1= 14 x 16 = 224 + F x 16º = 15 x 1 = 15
Sum = (3567)
10Converting Hexadecimal to Decimal
Shortcut Method for Converting a Binary
Number to its Equivalent Octal Number
Shortcut Method for Converting an Octal
Number to Its Equivalent Binary Number
Shortcut Method for Converting a Binary
Number to its Equivalent Hexadecimal Number
Shortcut Method for Converting a Hexadecimal
Number to its Equivalent Binary Number
63
Q.1- (EF)
16+ (27)
8= (?)
7(EF)
16= E x 16
1+ F x 16º
= 14 x 16 + 15 x 1
= 224 + 15 = (239)
10(27)
8= 2 x 8
1+ 7x8º = 16 + 7 = 23 (EF)
16+ (27)
8= (239)
10+ (23)
10= (262)
10= (523)
7Q.2- (C2D51)
16+ (27655)
8= (?)
6Some Problems
Data Representation
• Computer Codes:
• Computer codes are used for internal representation of data in computers.
• As computers use binary numbers for internal data representation, computer codes use binary coding schemes.
• In binary coding, every symbol that appears in the data is represented by a group of bits (usually called byte).
• Commonly used computer codes are BCD, EBCDIC, and ASCII
BCD
• BCD stands for Binary Coded Decimal.
• It is one of the early computer codes.
• It uses 6 bits to represent a symbol.
• It can represent 64 different characters.
Coding of Alphabetic Characters in BCD
Coding of Numeric Characters in BCD
BCD Coding Scheme
EBCDIC
• EBCDIC stands for Extended Binary Coded Decimal Interchange Code.
• It uses 8 bits to represent a symbol.
• It can represent 256 different characters.
Coding of Alphabetic Characters in
EBCDIC
Coding of Numeric Characters in
EBCDIC
EBCDIC Coding Scheme
ASCII
• ASCII stands for American Standard Code for Information Interchange.
• ASCII is of two types – ASCII-7 and ASCII-8.
• ASCII-7 uses 7 bits to represent a symbol and can represent 128 different characters.
• ASCII-8 uses 8 bits to represent a symbol and can represent 256 different characters.
• First 128 characters in ASCII-7 and ASCII-8 are same.
Coding of Alphabetic Characters in ASCII
Coding of Alphabetic Characters in ASCII
Coding of Numeric Characters in ASCII
ASCII-7 Coding Scheme
ASCII-8 Coding Scheme
What is a Programming Language
a language
to communicate with the machine
to perform some specific task
have keywords
follow certain rules
Why needed
• Is there any other better method to give instructions to computers ?
• Would you prefer to give instructions to machines in binary commands ?
• Machine language is difficult to understand.
• PL is an interface between humans and computers.
Why so many programming languages
• Available resources
• Different tools for different jobs
• Ruby and JavaScript are great for building web sites
• Java and C++ are often used for financial trading
• Python and R are good for data analytics.
• They evolve (New programming languages often learn from existing languages and add, remove and combine features in a new way.)
• Developers have tastes (A programming language is a tool for humans to express ideas to computers. While we developers have many things in common, there is natural variety in the way our minds work. Ex- some like fliexibity of pointers & most of us don‟t like
pointers).
PLs
• The only language a computer can understand is machine language (strings of 0 and 1).
• Binary opcodes are difficult to remember and it is hard to tell the difference between data and instructions.
Assembly language
• each instruction is presented in more human-readable form.
• If e9 represents addition instruction; „add‟ can be used in place of e9, called mnemonics.
• But before executing, you have to convert assembly language into m/c language.
• Assembly language is machine dependent & OS dependent.
High level PLs
• This problem of machine dependency should be removed
• Need for more expressivity and portability.
• High-level programming languages came into picture to solve above-mentioned issues.
Classification of PLs
• Imperative
• Declarative
• functional
• object oriented
oStructured (Modular) oObject-oriented
Structured (Modular) Programming
• Structured programming is a programming paradigm aimed at improving the clarity, quality, and development time of a computer program.
• makes extensive use of the structured control flow constructs such as:
• selection (if/then/else)
• repetition (while and for)
• block structures
• subroutines (functions)
Subroutines (Functions)
• A subroutine is a sequence of program instructions that perform a specific task, packaged as a unit.
• Advantages:
• Decomposing a complex programming task into simpler steps.
• Reducing duplicate code within a program.
• Enabling reuse of code across multiple programs.
• Hiding implementation details from users of the subroutine.
Advantages of Structured Programming
• Structured programs are easier to read and understand.
• Structured programs are easier to maintain.
• They require less effort and time for development.
• They are amenable to easier debugging and usually fewer errors are made in the course of writing such programs.
Disadvantages of Structured Programming
• Structured programming is not very suitable for the development of large programs.
• and does not allow much reusability code.
• does not support object-oriented concepts.
Object Oriented Programming (OOP)
• Object Oriented Programming (OOP) uses object oriented constructs or programming in an environment where some object oriented principles are followed.
• Object-oriented programming (OOP) is based on the concept of "objects", which may contain data, in the form of variables, often known as data
members; and code, in the form of methods, often known as member functions.
Concepts in OOP
• Object : Any entity that has state and behavior is known as an object. For example: chair, pen, table, keyboard, bike etc. It can be physical and
logical.
• Class: blueprint/Collection of objects is called class.
• Inheritance: When one object acquires all the properties and behaviours of parent object i.e. known as inheritance. It provides code reusability.
Concepts in OOP
• Polymorphism: When one task is performed by different ways i.e. known as polymorphism. Function overloading and function overriding are the examples of polymorphism.
• Abstraction: Hiding internal details and showing functionality is known as abstraction. In java, abstract class and interface provide abstraction.
• Encapsulation: Binding (or wrapping) code and data together into a single unit is known as encapsulation. Class is the example of encapsulation.
Advantages of OOP
• OOPs makes development and maintenance easier where as in structured programming language, it is not easy to manage if code grows as project size grows.
• OOPs provides data hiding whereas in structured programming language a global data can be accessed from anywhere.
• OOPs provides ability to simulate real-world event much more effectively.
Language translators
• Computer understands only machine language.
• A programming language translator is the piece of software that translate a computer program written in some specific programming language into another programming language (Machine language).
• Example-
• Assembler
• Compiler
• Interpreter
Assembler
• The assembler converts a program written in assembly language into machine code.
• An assembler works by assembling and converting the source code of assembly language into object code.
• An object file constitutes a stream of zeros and ones of machine code, which are directly executable by the processor.
Compiler
• The compiler is a program that converts a program written into a high- level programming language into machine code.
• The process of converting high-level programming into machine language is known as compilation.
• Generates a file usually called object file which is read by machine.
• Scans the entire program and translates it as a whole into machine code.
Interpreter
• An interpreter is a program that converts program written in high-level language into machine code understood by the computer.
• Translates program one statement at a time.
• No intermediate object code is generated.