0% found this document useful (0 votes)
7 views

Uniit 1

The document provides an overview of computer systems, detailing the components and functions of a computer, including the CPU, memory types (primary and secondary), and input/output devices. It explains the characteristics of computers, the hierarchy of memory, and the role of software, particularly operating systems and programming languages. Additionally, it describes the processes of compilation and interpretation, as well as the functions of linkers and loaders in software execution.

Uploaded by

Govind Singh
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)
7 views

Uniit 1

The document provides an overview of computer systems, detailing the components and functions of a computer, including the CPU, memory types (primary and secondary), and input/output devices. It explains the characteristics of computers, the hierarchy of memory, and the role of software, particularly operating systems and programming languages. Additionally, it describes the processes of compilation and interpretation, as well as the functions of linkers and loaders in software execution.

Uploaded by

Govind Singh
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/ 49

Unit 1

Computer System, Algorithm


Computer
• The word computer comes from the word “compute”, which means to
calculate.
• A computer is an electronic device which accepts data & set of
instructions from the user/input device & process it into useful
information which is displayed on its output device.
• Computer is an advanced electronic device that takes raw data as an
input from the user and processes it under the control of a set of
instructions (called program), produces a result (output), and saves it
for future use.
Characteristics of Computer
• Speed
• Accuracy
• Storage
• Programmability
• Diligence
• Versatility
• Emotionless
• Remembrance Power
Block Diagram of Digital Computer
Storage Unit

Secondary
Data Storage
Input Unit Information
Output Unit
Primary
Storage

Control Unit

Arithmatic
Data Flow
&Logical
Unit (ALU)
Control Flow

Central Processing Unit


Cont..
• Input Unit: The input unit consists of input devices that are attached to
the computer. These devices take input and convert it into binary
language that the computer understands. Some of the common input
devices are keyboard, mouse, joystick, scanner etc.
• Storage Unit: A storage unit in memory refers to the location or unit
where data is stored temporarily or permanently in a computer system.
It stores data, programs, final results as well as intermediate results. Its
main function is to store information. Memory is divided into storage
units that hold data, and these units can be of various sizes, typically
represented in bytes (8 bits). It can be further classified into two main
categories:
• Primary Memory (Primary Memory)
• Secondary Memory (Auxiliary Memory)
Cont..
• Primary Memory: Primary memory refers to the volatile memory that
is directly accessible by the CPU. It holds data and instructions that
are currently in use or being processed. Once the power is turned off,
the contents of primary memory are lost. This memory has very
limited capacity as it is very expensive and generally made up of
semiconductor devices.
• Secondary Memory: Secondary memory is non-volatile, meaning it
retains data even when the power is turned off. It is used to store
data and programs permanently or for long-term use. It stores
operating system, data files, system and application software etc.
Secondary memory is slower than primary memory, but it has a much
larger storage capacity.
Cont..
• Central Processing Unit (CPU) : Once the information is entered
into the computer by the input device, the processor processes it. The
CPU is called the brain of the computer because it is the control center
of the computer. It first fetches instructions from memory and then
interprets them so as to know what is to be done. If required, data is
fetched from memory or input device. Thereafter CPU executes or
performs the required computation and then either stores the output or
displays on the output device. The CPU has three main components
which are responsible for different functions – Arithmetic Logic Unit
(ALU), Control Unit (CU) and Memory registers
• Arithmetic and Logic Unit (ALU) : The ALU, as its name suggests
performs mathematical calculations and takes logical decisions.
Arithmetic calculations include addition, subtraction, multiplication
and division. Logical decisions involve comparison of two data items
to see which one is larger or smaller or equal.
Cont..
• Control Unit : The Control unit coordinates and controls the data flow in
and out of CPU and also controls all the operations of ALU, memory
registers and also input/output units. It is also responsible for carrying out
all the instructions stored in the program. It decodes the fetched instruction,
interprets it and sends control signals to input/output devices until the
required operation is done properly by ALU and memory.
• Memory Registers : A register is a temporary unit of memory in the CPU.
These are used to store the data which is directly used by the processor.
Registers can be of different sizes(16 bit, 32 bit, 64 bit and so on) and each
register inside the CPU has a specific function like storing data, storing an
instruction, storing address of a location in memory etc. The user registers
can be used by an assembly language programmer for storing operands,
intermediate results etc. Accumulator (ACC) is the main register in the ALU
and contains one of the operands of an operation to be performed in the
ALU.
Memory
• A memory is like a human brain. It is used to store data and instructions.
• A physical device that stores data or information temporarily or permanently in it
is called memory. It’s a device where data is stored and processed.
• Memory is divided into a large number of small parts called cells. Each location or
cell has a unique address.
• Types:
• Registers
• Cache Memory
• Primary Memory
• Secondary Memory
• Registers: It is very fast computer memory used to speed up the execution of
computer by providing quick access to commonly used data.
Cache Memory
• It is a type of high-speed memory which is small in size but faster than
main memory. The CPU can access it more quickly than primary
memory. So, it is used to synchronize with high speed CPU and to
improve its performance.
• Advantages of Cache Memory
• It is faster than the main memory.
• When compared to the main memory, it takes less time to access it.
• It keeps the programs that can be run in a short amount of time.
• It stores data in temporary use.
• Disadvantages of Cache Memory
• Because of the semiconductors used, it is very expensive.
• The size of the cache (amount of data it can store) is usually small.
Primary Memory
• It is also known as the main memory of the computer system.
• It is used to store data and programs or instructions during computer
operations.
• It uses semiconductor technology and hence is commonly called
semiconductor memory. It is not as fast as registers.
• Primary memory is of two types:
• RAM
• ROM
RAM (Random Access Memory)
• It is a volatile memory. Volatile memory stores information based on
the power supply.
• If the power supply fails/ interrupted/stopped, all the data and
information on this memory will be lost.
• It temporarily stores programs/data which has to be executed by
the processor.
• RAM is of two types:
• SRAM (Static RAM): SRAM uses transistors and the circuits of this memory
are capable of retaining their state as long as the power is applied. This
memory consists of the number of flip flops with each flip flop storing 1 bit. It
has less access time and hence, it is faster.
• DRAM (Dynamic RAM): DRAM uses capacitors and transistors and stores
the data as a charge on the capacitors. They contain thousands of memory
cells. It needs refreshing of charge on capacitor after a few milliseconds. This
memory is slower than SRAM.
ROM (Read Only Memory)
• It is a non-volatile memory. Non-volatile memory stores information
even when there is a power supply failed/ interrupted/stopped.
• As its name refers to read-only memory, we can only read the
programs and data that is stored on it.
• It is also known as permanent memory. ROM is of four types:
• MROM(Masked ROM): Hard-wired devices with a pre-programmed
collection of data or instructions were the first ROMs. Masked ROMs are a
type of low-cost ROM that works in this way.
• PROM (Programmable Read Only Memory): It is modifiable once by the
user. The user purchases a blank PROM and uses a PROM program to put the
required contents into the PROM. Its content can’t be erased once written.
Cont..
• EPROM (Erasable Programmable Read Only Memory): EPROM is an
extension to PROM where you can erase the content of ROM by exposing it
to Ultraviolet rays for nearly 40 minutes.
• EEPROM (Electrically Erasable Programmable Read Only
Memory): Here the written contents can be erased electrically. One can delete
and reprogram EEPROM up to 10,000 times. Erasing and programming take
very little time, i.e., nearly 4 -10ms(milliseconds). Any area in an EEPROM
can be wiped and programmed selectively.
Secondary Memory
• It is also known as auxiliary memory and backup memory.
• It is a non-volatile memory and used to store a large amount of data
or information.
• The data or information stored in secondary memory is permanent,
and it is slower than primary memory.
• A CPU cannot access secondary memory directly. The
data/information from the auxiliary memory is first transferred to the
main memory, and then the CPU can access it.
• Characteristics of Secondary Memory
• It is a slow memory but reusable.
• It is a reliable and non-volatile memory.
• It is cheaper than primary memory.
• The storage capacity of secondary memory is large.
• A computer system can run without secondary memory.
• In secondary memory, data is stored permanently even when the power is
off.
Types of Secondary Memory
• Magnetic Tapes
• Magnetic Disk : Floppy Disk, Hard Disk
• Optical Disks : CD, DVD
• Removable Disk: Pendrive
Memory Hierarchy
Memory Unit
• Memory Units are used to represent data. Some of the commonly used units
are:
• Bit: It is the smallest memory unit to measure the data stored in main
memory and storage devices.
• 4 bits = 1 Nibble
• 8 bits = 1 Byte
• 1024 bytes = 1KB (KiloByte)
• 1024 KB = 1 MB (MegaByte)
• 1024 MB = 1GB (GigaByte)
• 1024 GB = 1 TB (TeraByte)
• 1024 TB = 1 PB (PetaByte)
Central Processing Unit
• The processor or CPU is the brain of your computer.
• It performs all types of data processing information.
• It performs program tasks, calculates data from input, and manages and
coordinates other parts like memory, devices connected to the
computer.
Components of CPU
• ALU (Arithmetic Logic Unit)
• Control Unit
• Memory Unit
ALU
• ALU (Arithmetic Logic Unit) performs arithmetic and logical
functions or operations. It consists of two parts:
• Arithmetic Section: It performs operations like addition, subtraction,
multiplication, and division. All the complex operations are done by
making repetitive use of the mentioned operations by ALU.
• Logic Section: It performs operations like selecting, comparing,
matching, and merging the data.
Control Unit
• Controlling of data and transfer of data and instructions is done by the
control unit among other parts of the computer.
• It manages and coordinates all the units of the computer.
• It obtains the instructions or data from the memory unit, interprets
them, and then directs the operation of the computer according to that.
• It communicates with input and output devices for the transfer of data
or results from memory.
• It does not process or store data.
Memory Unit
• It stores data and instructions required for processing.
• It stores the intermediate results of processing.
• It stores the final results of processing before these results are released
to an output device.
• All inputs and outputs are transmitted through the memory unit.
Input Devices
• The input device enables the user to send data, information or
control signals to computer.
• The CPU receives the input and processes it to produce the output.
• Keyboard
• Mouse
• Joystick
• Lightpen
• Trackball
Output Device
• Output Devices are the devices that show us the result after giving the
input to a computer system. Output can be of many different forms like
image, graphic audio, video, etc. Some of the output devices are described
below.
• Printer
• Impact Printer : Dot Matrix Printers, Drum Printers etc
• Non Impact Printer: Laser Printer, Inkjet Printer etc
• Speakers
• Projectors
• Monitor
• CRT Monitor
• LCD Monitor
• LED Monitor
• Plasma Monitor
Software
• Software refers to the collection of programs, data, and instructions
that tell the computer hardware how to perform specific tasks. Unlike
hardware, which consists of physical components (like the CPU,
keyboard, etc.), software is intangible and is designed to carry out
operations and solve specific problems.
• In simple terms, software is the bridge between the user and the
hardware, enabling users to interact with the computer and carry out
various tasks like browsing the web, editing documents, playing
games, and much more.
• Types: System Software, Application Software
Cont..
• System Software: System software is designed to manage and control
the computer hardware and provide a platform for running application
software. It serves as a bridge between the user and the hardware. Ex:
Operating System, Device Drivers, utility software etc
• Application Software: Application software refers to programs that are
designed to help users perform specific tasks, such as word processing,
browsing the web, or editing photos. These are programs that end-
users interact with directly. Eg: Productivity software, Media software,
web browsers, DBMS etc
Operating System
• An operating system can be defined as an interface between the user
and the hardware.
• An operating system is a program that acts as an interface between
the software and the computer hardware.
Characteristic of OS
• Process Management
• Memory Management
• Device Management
• File Management
• Security
Computer Languages
• Computer languages are formal languages used to give instructions
to computers, enabling them to perform specific tasks. These
languages are used to write software programs, algorithms, and
applications that interact with computer hardware. There are several
different types of computer languages, each serving different
purposes and working at different levels of abstraction.
• Types:
• Low Level : Machine Language, Assembly Language
• High Level: C , C++, JAVA, FORTRAN, COBOL etc
Translators
• Assembler
• Compiler
• Interpreter
Assembler
• An assembler translates assembly language program into machine
code. The output of an assembler is called an object file, which
contains a combination of machine instructions as well as the data
required to place these instructions in memory.
Compiler
• The language processor that reads the complete source program
written in high-level language as a whole in one go and translates it
into an equivalent program in machine language is called a Compiler.
Interpreter
• The translation of a single statement of the source program
into machine code is done by a language processor and
executes immediately before moving on to the next line is
called an interpreter.
Difference
Compiler Interpreter

A compiler is a program that converts the entire source code of An interpreter takes a source program and runs it line by line,
a programming language into executable machine code for a CPU. translating each line as it comes to it.

The compiler takes a large amount of time to analyze the entire source
An interpreter takes less amount of time to analyze the source code but
code but the overall execution time of the program is comparatively
the overall execution time of the program is slower.
faster.

The compiler generates the error message only after scanning the
Its Debugging is easier as it continues translating the program until the
whole program, so debugging is comparatively hard as the error can be
error is met.
present anywhere in the program.

It requires less memory than a compiler because no object code is


The compiler requires a lot of memory for generating object codes.
generated.

Generates intermediate object code. No intermediate object code is generated.

For Security purpose compiler is more useful. The interpreter is a little vulnerable in case of security.

Examples: C, C++, C# Examples: Python, Perl, JavaScript, Ruby.


Linker and Loader
• A linker is a special program that combines the object files, generated
by the compiler/assembler and other pieces of code to originate an
executable file has .exe extension.
• A loader is a special program that takes input of executable files from
linker, loads it to main memory, and prepares this code for execution
by computer. It calculates the size of a program and creates memory
space for it.
Difference
LINKER LOADER

It generates executable files of a source file. It loads executable files to the main memory.

The linker takes input of object code generated by And the loader takes input of executable files generated by
compiler/assembler. linker.

Linking can be defined as process of combining various Loading can be defined as process of loading executable
pieces of codes and source code to obtain executable code. codes to main memory for further execution.

Loaders are of 4 types: Absolute, Relocating, Direct Linking,


Linkers are of 2 types: Linkage Editor and Dynamic Linker.
Bootstrap.

Another use of linker is to combine all object modules. It helps in allocating the address to executable codes/files.

Linker is also responsible for arranging objects in program’s Loader is also responsible for adjusting references which are
address space. used within the program.
Algorithm
• A set of finite rules or instructions to be followed in calculations or
other problem-solving operations
Characteristics of Algorithm
Cont..
• Unambiguous: The algorithm should be unambiguous and clear. Each
of its steps should be clear in all aspects and must lead to only one
meaning.
• Inputs: It should have 0 or more well-defined inputs.
• Outputs: An algorithm should have 1 or more well defined outputs
and should match the desired output.
• Finite-ness: The algorithm must be finite, i.e. it should terminate after
a finite time.
• Feasible: The algorithm must be simple, generic, and practical, such
that it can be executed with the available resources.
• Language Independent: An algorithm should have step by step
directions , which should be independent of any programming
language.
Algorithm to add 3 numbers and print their
sum

1.START
2.Declare 3 integer variables num1, num2, and num3.
3.Take the three numbers, to be added, as inputs in variables num1, num2,
and num3 respectively.
4.Declare an integer variable sum to store the resultant sum of the 3 numbers.
5.Add the 3 numbers and store the result in the variable sum.
6.Print the value of the variable sum
7.END
Flowchart
• A flowchart is a graphical representation of an algorithm.
• Advantages
• It shows the logic of the system.
• It provides the blueprint of the program.
• It helps in the debugging process.
• It helps in analyzing the program.
• It provides better documentation.
• Easy to trace errors in the software.
• Easy to understand.
Disadvantage
• It is difficult to draw flowcharts for large and complex programs.
• There is no standard to determine the amount of detail.
• Difficult to reproduce the flowcharts.
• It is difficult to modify the flowchart.
• Making a flowchart is costly.
• It makes software processes slow.
• If changes are done in software, then the flowchart must be redrawn
Input two numbers from the user and display the largest of two numbers
Difference
Algorithm Flowchart

A flowchart is a diagram created with different shapes to show the


An algorithm is a step-by-step procedure to solve a problem.
flow of data.

The algorithm is complex to understand. A flowchart is easy to understand.

In the algorithm, plain text is used. In the flowchart, symbols/shapes are used.

The algorithm is easy to debug. A flowchart is hard to debug.

The algorithm is difficult to construct. A flowchart is simple to construct.

The algorithm does not follow any rules. The flowchart follows rules to be constructed.

The algorithm is the pseudo-code for the program. A flowchart is just a graphical representation of that logic.
Pseudocode
• A Pseudocode is defined as a step-by-step description of an algorithm.
• It does not use any programming language instead it uses the simple
English language text as it is intended for human understanding rather
than machine reading.
• It is the intermediate state between an idea and its
implementation(code) in a high-level language.
Source Code
• It is the original code written by developers using a programming
language.
• Readable by humans, written in high-level programming languages,
requires translation into machine code.
• Primary form of code created by developers.
Assignment
Q1. Write the difference between RAM and ROM.
Q2. Write the difference between SRAM and DRAM.
Q3. Write the difference between Primary memory and Secondary
memory.
Q4. Write the difference between object code and executable code.
Q5. Write an algorithm that takes two input x and y from the user and if
x>y then find the product of the numbers or else find the sum of the
numbers and display the output.

You might also like