0% found this document useful (0 votes)
39 views28 pages

UNIT1 (Theory)

The document discusses the functional units of a digital computer including input, storage, processing, and output units. It describes the input unit which accepts data from external devices, the storage unit which holds data and instructions, and the central processing unit which performs calculations and controls other units. It also defines primary memory such as RAM and ROM, secondary storage devices, and the cache memory.

Uploaded by

sarthakmalik5098
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)
39 views28 pages

UNIT1 (Theory)

The document discusses the functional units of a digital computer including input, storage, processing, and output units. It describes the input unit which accepts data from external devices, the storage unit which holds data and instructions, and the central processing unit which performs calculations and controls other units. It also defines primary memory such as RAM and ROM, secondary storage devices, and the cache memory.

Uploaded by

sarthakmalik5098
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/ 28

Programming For Problem Solving

UNIT-I

1/11/2022 MIET Group of Institutions. 1


FUNCTIONAL UNITS OF DIGITAL COMPUTER
Computer: Computer is an electronics device that can perform various
arithmetic and logical operations. It can receive data, process it and
produce output. It can store large amount of data.

1/11/2022 MIET Group of Institutions. 2


FUNCTIONAL UNITS OF DIGITAL COMPUTER

• A digital computer is considered to be a calculating device that can perform arithmetic


operations at enormous speed.
• 1. Input Unit: The commonly used input devices are mouse, floppy disk drive, magnetic
tape etc. Thus, we can conclude that, all the input devices accepts the data and
instruction from outside world, convert it to a form that the computer can understand,
supply the converted data to the computer system for further processing.
• 2. Storage Unit: The storage unit of a computer holds data and instructions that are
entered through the input unit, before they are processed. It stores programs, data
as well as intermediate results and results for output. Its main function is to store
information.

1/11/2022 MIET Group of Institutions. 3


FUNCTIONAL UNITS OF DIGITAL COMPUTER
• Memory can be classified as following:
a. Primary Memory can be further classified as RAM and ROM.
• RAM or Random Access Memory is the unit in a computer system. It is the place in a
computer where the operating system, application programs and the data in current
use are kept temporarily so that they can be accessed by the computer’s processor. It
is said to be ‘volatile’ since its contents are accessible only as long as the computer is
on. The contents of RAM are no more available once the computer is turned off.
• ROM or Read Only Memory is a special type of memory which can only be read and
contents of which are not lost even when the computer is switched off. It typically
contains manufacturer’s instructions. Among other things, ROM also stores an initial
program called the ‘bootstrap loader’ whose function is to start the operation of
computer system once the power is turned on.
• b. Secondary Memory
• These include devices that are peripheral and are connected and controlled by the
computer to enable permanent storage of programs and data.
• Secondary storage devices are of two types; magnetic and optical. Magnetic devices
include hard disks and optical storage devices are CDs, DVDs, Pen drive, Zip drive etc
• Cache memory: Cache memory is an extremely fast memory type that acts as a buffer
between RAM and the CPU. It holds frequently requested data and instructions so that
they are immediately available to the CPU when needed.

1/11/2022 MIET Group of Institutions. 4


FUNCTIONAL UNITS OF DIGITAL COMPUTER
• 3. Central Processing Unit (CPU): The control unit and arithmetic logic unit of
computer are together known as central processing unit (CPU). The CPU is like brain
and performs following functions: It performs all calculations, it takes all decisions,
and it controls all units of a computer.
(a) Control Unit: It manages and coordinates the entire computer system and
synchronizes its working, thus referred to as “Central Nervous System” or “Brain of
the Computer”.

(b) Arithmetic and Logic Unit: The function of an Arithmetic logic unit (ALU) is to
perform arithmetic and logical operations such as addition, subtraction, multiplication,
division, AND, OR, NOT, Exclusive OR etc.

(c) Registers: small memory used intermediate results and for some special purpose.
• 4. Output Unit: An output unit performs the reverse operation of that of an input
unit so it supplies information obtained from processing to outside world. Units
called output interfaces accomplish this task.

1/11/2022 MIET Group of Institutions. 5


CLASSIFICATION OF COMPUTER

S. No Computer Type Features

 The fastest and most powerful type of computer Supercomputers are very
expensive and are employed for specialized applications that require immense
amounts of mathematical calculations.
1 Super Computer
 For example, weather forecasting requires a supercomputer. Other uses of
supercomputers include animated graphics, fluid dynamic calculations, nuclear
energy research, and petroleum exploration.

 A very large and expensive computer capable of supporting hundreds, or even


Mainframe thousands, of users simultaneously.
2
Computer  For example, online reservation system, online banking system, In hierarchy
mainframes are just below supercomputers.

1/11/2022 MIET Group of Institutions. 6


CLASSIFICATION OF COMPUTER CONTINUE…

S. No Computer Type Features

 A midsized computer. In size and power, minicomputers lie


between workstations and mainframes.
3 Mini Computer
 But in general, a minicomputer is a multiprocessing system capable of
supporting from 4 to about 200 users simultaneously.
• A terminal or desktop computer in a network. In this context,
workstation is just a generic term for a user's machine (client
4 Workstations
machine) in contrast to a "server" or "mainframe." (Workstations lie
between mini computer and personal computer).
• Desktop Computer: a personal or micro-mini computer sufficient to
fit on a desk.
Micro Computer or Personal
5  Laptop Computer: a portable computer complete with an integrated
Computer
screen and keyboard. It is generally smaller in size than a desktop
computer and larger than a notebook computer.

1/11/2022 MIET Group of Institutions. 7


HARDWARE AND SOFTWARE

Basics Hardware Software


Software is a collection of program
Devices that are required to store and
Definition that enables a computer to perform a
execute (or run) the software.
specific task
Input, storage, processing, control, System software, Programming
Types
and output devices. software, and Application software.
QuickBooks, Adobe Acrobat, Google
CD-ROM, monitor, printer, video card,
Examples Chrome, Microsoft Word, Microsoft
scanners
Excel
Software does not wear out over time.
Durability Hardware wears out over time. However, bugs are discovered in
software as time passes.
Nature Hardware is physical in nature. Software is logical in nature.

1/11/2022 MIET Group of Institutions. 8


SYSTEM & APPLICATION SOFTWARE

BASIS SYSTEM SOFTWARE APPLICATION SOFTWARE


System Software manages system Application Software, when run,
Basic resources and provides a platform for perform specific tasks, they are
application software to run. designed for.
Application Software is written in a
System Software is written in a low-
Language high-level language like Java, C++, .net,
level language, i.e. assembly language.
VB, etc.
System Software starts running when
Application Software runs as and
Run the system is turned on, and runs till
when the user requests.
the system is shut down.
Application Software is specific-
Purpose System Software is general-purpose.
purpose.
Microsoft Office, Photoshop,
Examples Operating system.
Animation Software, etc.

1/11/2022 MIET Group of Institutions. 9


LOW LEVEL AND HIGH LEVEL PROGRAMMING LANGUAGE

Low level language High level language

Advantage Disadvantage

They are faster than high level language. They are comparatively slower.

Low level languages are memory efficient. High level languages are not memory efficient.

No need of translator except assembler for AL. Compiler & Interpreter is needed to convert HLL.

Disadvantage Advantage

Low level languages are difficult to learn. High level languages are easy to learn.

They are machine dependent and are not portable. They are machine independent and portable.

They are more error prone. They are less error prone.

Debugging and maintenance is difficult. Debugging and maintenance is comparatively easier.

Ex: Machine/Assembly Language Ex: C, C++, Java

1/11/2022 MIET Group of Institutions. 10


ROLE OF ASSEMBLER IN SYMBOLIC LANGUAGE

• Assembler: An assembler is a system program, which convert an assembly language


program in to machine language program, Example (Merlin, Vasm).

1/11/2022 MIET Group of Institutions. 11


COMPILER & INTERPRETER

Basics Compiler Interpreter


It Scans the entire program and
Translates program one statement at
Definition translates it into machine code (As
a time (Line by Line)
Whole)
Error Display Display the syntax errors as a whole Display the syntax errors line by line

Execution Time The overall execution time is faster The overall execution time is slower

Debugging Debugging is hard Debugging is easy


. obj file is not created using
.obj File . obj file is created using compiler
interpreter
Programming language like Python,
Programming language like C, C++ uses
Example Ruby, Java uses interpreters. (Java
compilers. (Turbo C, GCC)
Interpreter)

1/11/2022 MIET Group of Institutions. 12


OPERATING SYSTEM

• An Operating System (OS) is a system program which provides an interface between


computer user and computer hardware. Some popular Operating Systems include UNIX,
Linux, and Windows etc.
• Resource Manager/Allocator: An operating system is termed as resource manager or
resource allocator, as its provides all necessary resources (Hardware, Software or
Files) to application execution inside a computer system, like to play a song, OS
allocates operational mouse, monitor, speaker, ram, hard disk, buses, processor etc to
application.
• Following are some of important functions of an operating System.
• Memory Management
• Processor Management
• Device Management
• File Management
1/11/2022 MIET Group of Institutions. 13
• Security
CLASSIFY THE OPERATING SYSTEM

Multi Programming OS Multi Tasking OS Multi Threading OS

 Multitasking refers to having


 Multithreading is an execution
multiple (programs, processes,
 In a multiprogramming system model that allows a single process
tasks, threads) running at the
there are one or more programs to have multiple code segments (i.
same time.
loaded in main memory which are e., threads) run concurrently
 This term is used in modern
ready to execute. within the “context” of that
operating systems when multiple
 Only one program at a time is able process.
tasks share a common processing
to get the CPU for executing its  You can think of threads as child
resource (e.g., CPU and Memory).
instructions (i.e., there is at processes that share the parent
At any time the CPU is executing
most one process running on the process resources but execute
one task only while other tasks
system) while all the others are independently.
waiting their turn.
waiting their turn.  Multiple threads of a single
 The illusion of parallelism is
 The main idea of process can share the CPU in a
achieved when the CPU is
multiprogramming is to maximize single CPU system or (purely) run
reassigned to another task (i.e.
the use of CPU time. in parallel in a multiprocessing
process or thread context
system
switching).

1/11/2022 MIET Group of Institutions. 14


CUI & GUI OPERATING SYSTEM

BASIS CLI/CUI GUI

Graphical User interface permits a


Command line interface enables a user
user to interact with the system by
Basic to communicate with the system
using graphics which includes images,
through commands.
icons, etc.

Device used Keyboard Mouse and keyboard

Hard to perform an operation and Easy to perform tasks and does not
Ease of Use
require expertise. require expertise.

Memory Low Consumption High Consumption

Appearance Can't be changed Custom changes can be employed

Speed Fast Slow

1/11/2022 MIET Group of Institutions. 15


ANDROID & WINDOWS OS

Basis Android Windows

Graphics Optimized Full fledged

Source Code Open source code Close source code

Security Less More

Application For Mobile For PC

Developer Google Microsoft

1/11/2022 MIET Group of Institutions. 16


ALGORITHM & CHARACTERISTICS OF ALGORITHM

• A step-by-step method of solving a problem or making decision is termed as algorithm.

Properties of the algorithm


• Input. An algorithm has zero or more inputs, i.e., quantities which are given to it
initially before the algorithm begins.
• Output. An algorithm has one or more outputs i.e., quantities which have a specified
relation to the inputs.
• Finiteness. An algorithm must always terminate after a finite number of steps.
• Definiteness. Each step of an algorithm must be precisely defined; the actions to be
carried out must be rigorously and unambiguously specified for each case.
• Effectiveness. An algorithm is also generally expected to be effective. This means that
all of the operations to be performed in the algorithm must be sufficiently basic that
they can in principle be done exactly and in a finite length of time.

1/11/2022 MIET Group of Institutions. 17


ADVANTAGE & DISADVANTAGE

Advantages of algorithm
• An algorithm uses a definite procedure which makes it easy to understand.
• It is not dependent on any programming language, so it is easy to understand.
• Every step in an algorithm has its own logical sequence so it is easy to debug.
• By using algorithm, the problem is broken down into smaller pieces or steps.

Disadvantages of algorithm.
• Writing algorithm takes a long time.
• An Algorithm is not a computer program; it is rather a concept of how a program
should be.

1/11/2022 MIET Group of Institutions. 18


ALGORITHM EXAMPLES

• Write an algoritham to find an addition of two number


step:-1 Start
step:-2 input a and b
step:-3 c=a+b
step:-4 print c
step:-5 Stop
• Write an algorithm to find largest of three numbers
step:-1 Start
step:-2 input a , b and c
step:-3 if a>=b and a>=c then goto 4 otherwise go to 5.
step:-4 print a goto 8
step:-5 if b>=c goto 6 otherwise go to 7
step:-6 print b goto 8
step:-7 print c
step:- 8 Stop

1/11/2022 MIET Group of Institutions. 19


FLOWCHARTS AND ITS NOTATIONS

• 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.

Advantages of flowchart:
• The Flowchart is an excellent way of communicating the logic of a program.
• It is easy and efficient to analyze problem using flowchart.
• It helps the programmer to write the program code.

Disadvantage of flowchart
• The flowchart can be complex when the logic of a program is quite complicated.
• Drawing flowchart is a time-consuming task.
• Difficult to alter the flowchart & uses special sets of symbols for every action.
• It is just a visualization of a program; it cannot function like an actual program.
1/11/2022 MIET Group of Institutions. 20
FLOWCHARTS AND ITS NOTATIONS

Symbol Symbol Name Purpose

Used at the beginning and end of


Start/Stop the algorithm to show start and
end of the program.
Indicates processes like
Process
mathematical operations.
Used for denoting program inputs
Input/ Output
and outputs.
Stands for decision statements in a
Decision program, where answer is usually
Yes or No.
Connector use to connect the flow of two of
more flow charts
Shows relationships between
Arrow
different shapes.

1/11/2022 MIET Group of Institutions. 21


Example- Draw the flow chart of simple interest.

1/11/2022 MIET Group of Institutions. 22


Example- Draw the flow chart of largest of three numbers.

1/11/2022 MIET Group of Institutions. 23


Example- Draw the flow chart of average of N numbers.
Note: replace 3 with any number.

1/11/2022 MIET Group of Institutions. 24


PSEUDO CODE

• Definition: Pseudocode is an informal way of programming description that does not


require any strict programming language syntax or underlying technology
considerations. It is used for creating an outline or a rough draft of a program.
Pseudocode summarizes a program’s flow, but excludes underlying details. System
designers write pseudocode to ensure that programmers understand a software
project's requirements and align code accordingly.

Advantages of pseudo code:


• Pseudocode is understood by the programmers of all types.
• It enables the programmer to concentrate only on the algorithm part of the code
development.
• It cannot be compiled into an executable program.

1/11/2022 MIET Group of Institutions. 25


PSEUDO CODE CONTINUE…

Example: Average of 10 numbers

Set total = 0

Set I =1

While i is less than or equal to 10

Input the next number

Add the number into the total

I = I +1

Set the average to the total divided by 10

Print the average.

1/11/2022 MIET Group of Institutions. 26


STRUCTURED/PROCEDURAL PROGRAMMING

• Structured programming techniques use functions or subroutines to organize the


programming code. The programming purpose is to break the large code into smaller
pieces and organized together using function.
• This technique uses the concept of modularization/top down design approach to
provide cleaner code and simplifies maintaining the program. Each function has its own
identity and isolated from other, thus change in one function doesn’t affect other.

Features of Structured Programming


• Codes are simple to write & understand
• Concise & clear codes, easy to debug
• Effective & Efficient code Execution
• Scalability & reusability of functions

1/11/2022 MIET Group of Institutions. 27


1/11/2022 MIET Group of Institutions. 28

You might also like