Brainware University: Definition of Digital Computer

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

BRAINWARE UNIVERSITY

[CESCM201] CLASS NOTES [Programming for Problem Solving]

 Definition of Digital computer:


Digital Computer is a electronic machine or a device that helps to process any kind of
information. These are the devices through which users provide some input and get the output
within a fraction of seconds.

There are mainly three parts in a digital computer and it consists of –

Input: The user normally provides the data to the device that is known as input.
Processing: The input that is provided by the user is processed internally using some defined
sequence.
Output: Once the processing is completed, based on the input, the output is displayed to the user.
A digital computer computer is a combination of Hardware and Software.

Hardware:- Hardware refers to the physical components of a computer. Computer Hardware is


any part of the computer that we can touch these parts. Examples of hardware in a computer are
the Processor, Memory Devices, Monitor, Printer, Keyboard, Mouse.

Software:- Software is a collection of instructions, procedures, documentation that performs


different tasks on a computer system. Examples of software are Ms Word, Excel, Power Point,
Google Chrome, Photoshop, MySQL etc.

Computer software is classified into two types

1. Application Software:- Application software are used to perform a particular task. Examples
of application software are Ms Word, Excel, Power Point, Google Chrome, Photoshop, MySQL
etc.

2. System Software:- System software provides an environment on which application software


can execute and also provides an interface between user and computer hardware. Examples of
system software are operating system(OS), compiler, linker etc.

Among all system software OS is the primary one because without it user’s are unable to use
any computer hardware and perform any task. Examples of operating systems are different
version of Microsoft Windows like XP, Vista,7, 8,10 ,Unix, different distribution of Linux like
mint, fedora, Red Hat , MAC etc

 Types of computer on the basis of capacity

2021-22 Prepared by: Piyali De ( Brainware University, Barasat)


BRAINWARE UNIVERSITY
[CESCM201] CLASS NOTES [Programming for Problem Solving]

a) Super Computer

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

b) Mainframe Computer

A very large and expensive computer capable of supporting hundreds or even thousands of users
simultaneously. In the hierarchy computers mainframes are just below supercomputers.

Note: The chief difference between a supercomputer and a mainframe is that mainframes are
more powerful than supercomputers because they support more simultaneous programs. But
supercomputers can execute a single program faster than a mainframe.

c) Mini Computer

A minicomputer is a multiprocessing system capable of supporting from 4 to about 200 users


simultaneously.

d) Micro Computer

i. Desktop Computer: a personal or micro-mini computer sufficient to fit on a desk.

ii. Laptop Computer: a portable computer complete with an integrated screen and
keyboard. It is generally smaller in size than a desktop computer and larger than a
notebook computer.

iii. Palmtop Computer/Digital Diary /Notebook /PDAs: a hand-sized computer. Palmtops


have no keyboard but the screen serves both as an input and output device.

iv. Workstation: A workstation is simply a desktop computer that has a more powerful
processor, additional memory and enhanced capabilities for performing a special
group of task, such as 3D Graphics or game development.

2021-22 Prepared by: Piyali De ( Brainware University, Barasat)


BRAINWARE UNIVERSITY
[CESCM201] CLASS NOTES [Programming for Problem Solving]

 Introduction to components of a computer system

SECONDARY
MEMORY

PRIMARY
INPUT UNIT MEMORY OUTPUT UNIT

CU

ALU

CENTRAL PROCESSING
UNIT

A computer system consists of mainly four basic units


 input unit
 storage unit
 central processing unit
 output unit.
Central Processing unit further includes Arithmetic logic unit and control unit. Storage unit is divided
into two parts Primary and Secondary memory. These components of a computer performs four major
operations or functions
• it accepts data or instructions as input,
• it stores data and instruction
• it processes data as per the instructions,
• it gives results in the form of output.

Input Unit: - An input unit is device through which data and programs from user are entered into the
computer. The input unit links the external environment with the computer system. Input unit accepts
data and instruction in human readable form, but it transforms data and instructions into binary codes
before further processing. This transformation is accomplished by units that called input interfaces.
In short, an input unit performs the following functions.
1. It accepts (or reads) the list of instructions and data from the outside world.
2. It converts these instructions and data in computer acceptable format.

2021-22 Prepared by: Piyali De ( Brainware University, Barasat)


BRAINWARE UNIVERSITY
[CESCM201] CLASS NOTES [Programming for Problem Solving]

3. It supplies the converted instructions and data to the computer system for further processing.
Example : - Keyboard, mouse, scanner and bar-code reader.

Output Unit: - An output unit is a device through which results stored in the computer memory are
made available to the user. It links the computer with the external environment. As computers work with
binary code, the results produced are also in the binary form. Hence, before supplying the results to the
outside world, it must be converted to human acceptable (readable) form. This task is accomplished by
units called output interfaces.

In short, the following functions are performed by an output unit.


1. It accepts the results produced by the computer which are in coded form and hence cannot be
easily understood by us.
2. It converts these coded results to human acceptable (readable) form.
3. It supplied the converted results to the outside world.
Example: - Monitor, printer and speaker.

Storage Unit: - The data and instructions that are entered into the computer system through input units
have to be stored inside the computer before the actual processing starts. Similarly, the results produced
by the computer after processing must also be kept somewhere inside the computer system temporarily or
permanently before being passed on to the output units. Storage unit is designed for this perpose only.
the following functions are performed by an storage unit
1. All the data to be processed and the instruction required for processing (received from input
devices).
2. Intermediate results of processing.
3. Final results of processing before these results are released to an output device.
There are two types of storage unit available in all modern computers
 Primary Memory
 Secondary Memory
Primary Memory: - This type of memory is usually small in size but very fast. Primary Memory is
internal memory of the computer. RAM AND ROM both form part of primary memory. The primary
memory provides main working space to the computer.
 Ramdom Access Memory(RAM)/Main Memory: - the data and instructions
needs to be stored in the main memory before execution. The primary storage is referred to as
random access memory (RAM) because it is possible to randomly select and use any location of the
memory directly store and retrieve data. The storage of data and instructions inside the primary
storage is disappeared from RAM as soon as the power to the computer is switched off. That’s why
main memory is also known as volatile memory. There are two types os RAM
 Read Only Memory (ROM): - here is another memory in computer, which is
called Read Only Memory (ROM). The storage of program and data in the ROM is permanent. The
ROM stores some standard processing programs supplied by the manufacturers to operate the
personal computer. The ROM can only be read by the CPU but it cannot be changed. ROM does not

2021-22 Prepared by: Piyali De ( Brainware University, Barasat)


BRAINWARE UNIVERSITY
[CESCM201] CLASS NOTES [Programming for Problem Solving]

lose their content on failure of power suppl. That’s why, it is known as non-volatile memory. There
are different types of ROM available
o Programmable Read Only Memory(PROM): - Data is written into a ROM
at the time of manufacture. However the content can be programmed by user with a
special PROM programmer. PROM provides flexible and economical fixed programs
and data.
o Erasable Programmable Read Only Memory(EPROM): - this allow the
programmer to erase the contents of the ROM and reprogram it. The contents of the
EPROM cells can be erased using ultra violet light using EPROM programmer.
o Electrically Erasable Programmable Read Only Memory(EEPROM): - In
this type of ROM, the contents of the cells can be erased electrically, by applying a high
voltage. The EEPROM need not to be removed physically for reprogramming.
Secondary Memory: - Secondary memory is external and permanent in nature. The secondary memory
is concerned with magnetic memory. Secondary memory can be stored on storage media like floppy
disks, magnetic disks, magnetic tapes. This memory can also be stored optically on Optical disks - CD-
ROM. The following are the popular secondary memory:
 Magnetic Tape: Magnetic tapes are used for large computers like mainframe
computers where large volume of data is stored for a longer time. In PC also you can use tapes in
the form of cassettes. The cost of storing data in tapes is inexpensive. Tapes consist of magnetic
materials that store data permanently.
 Magnetic Disk: You might have seen the gramophone record, which is
circular like a disk and coated with magnetic material. Magnetic disks used in computer are made
on the same principle. It rotates with very high speed inside the computer drive. Data is stored on
both the surface of the disk. For Example-Floppy Disk.
 Optical Disk: With every new application and software there is greater
demand for memory capacity. It is the necessity to store large volume of data that has led to the
development of optical disk storage medium. Example Compact Disk/ Read Only Memory (CD-
ROM)
Central Processing Unit (CPU): - The main unit inside the computer is the CPU. This unit is
responsible for all events inside the computer. It controls all internal and external devices. The
control Unit and the Arithmetic and Logic unit of a computer system are jointly known as the Central
Processing Unit (CPU). The CPU is the brain of any computer system. In a human body, all major
decisions are taken by the brain and the other parts of the body function as directed by the brain.
Similarly, in a computer system, all major calculations and comparisons are made inside the CPU
and the CPU is also responsible for activating and controlling the operations of other units of a
computer system.
Arithmetic Logical Unit (ALU): - (ALU) of a computer system is the place where the actual
execution of the instructions take place during the processing operations. All arithmetic operation
such as addition, substation, multiplication and division are performed and all logical operation like
AND, OR, NOT (decisions) are made in the ALU. ALU has small amount of special memory unit
called registers.

2021-22 Prepared by: Piyali De ( Brainware University, Barasat)


BRAINWARE UNIVERSITY
[CESCM201] CLASS NOTES [Programming for Problem Solving]

Algorithm:-

An algorithm is a finite set of well defined instructions or step by step procedure to solve a given problem.
In other word, a sequential solution of any program that written in human language, called algorithm.
Algorithm is first step of the solution process, after the analysis of problem, programmer writes the
algorithm of that problem.

According to Knuth an algorithm must possess the following properties:

Finiteness: The algorithm must always terminate after a finite number of steps.

Definiteness: Each step must be precisely defined; the actions to be carried out must be rigorously and
unambiguously specified for each case.

Input: An algorithm has zero or more inputs, taken from a specified set of objects.

Output: An algorithm has one or more outputs, which have a specified relation to the inputs.

Effectiveness: All operations to be performed must be sufficiently basic that they can be done exactly
and in finite length.

Introduction to flowcharts

A flowchart is a graphical representation of an algorithm. These flowcharts play a vital role in the
programming of a problem and are quite helpful in understanding the logic of complicated and lengthy
problems. Once the flowchart is drawn, it becomes easy to write the program in any high level language.
Often we see how flowcharts are helpful in explaining the program to others. Hence, it is correct to say
that a flowchart is a must for the better documentation of a complex program.

Flowcharts are usually drawn using some standard symbols; however,

2021-22 Prepared by: Piyali De ( Brainware University, Barasat)


BRAINWARE UNIVERSITY
[CESCM201] CLASS NOTES [Programming for Problem Solving]

Start or end of the program

Computational steps or processing function of a


program

Input or output operation

Decision making and branching

Connector or joining of two parts of program

Problem 1: Write an algorithm and draw the flowchart for finding the average of two numbers
START
Algorithm:

Input: two numbers x and y Input x

Output: the average of x and y

Step 1: input x Input y

Step 2:input y
Sum = x + y
Step 3:sum = x + y
Step 4:average = sum /2
Step 5:output average Average = sum/2

Output
Average

END

2021-22 Prepared by: Piyali De ( Brainware University, Barasat)


BRAINWARE UNIVERSITY
[CESCM201] CLASS NOTES [Programming for Problem Solving]

Problem 2: Write an algorithm and draw the


flowchart for finding largest among two
numbers

Step 1: Start

Step 2: Read a, b .

Step 3: If a>b then

Display “a is the largest number”.

Step 4: Otherwise

Display “b is the largest number”.

Step 4: End.

Problem 3: Flowchart to find the greater of 3 numbers.

2021-22 Prepared by: Piyali De ( Brainware University, Barasat)


BRAINWARE UNIVERSITY
[CESCM201] CLASS NOTES [Programming for Problem Solving]

Problem 4 Flowchart to find the profit and loss.

Problem 5: Write an algorithm and draw the flowchart for Factorial of a given number.

Algorithm to calculate the factorial of a number

step 1. Start
step 2. Read the number n
step 3. [Initialize]
i=1, fact=1
step 4. Repeat step 4 through 6 until i=n
step 5. fact=fact*i
step 6. i=i+1
step 7. Print fact
step 8. Stop

2021-22 Prepared by: Piyali De ( Brainware University, Barasat)


BRAINWARE UNIVERSITY
[CESCM201] CLASS NOTES [Programming for Problem Solving]

Problem 6: Write an algorithm and draw the flowchart for Fibonacci series up to n terms.

Source code, Object code and executable code:-


Source code:- Source code contains statements that are written by a human known as a programmer in
any high level languages such as Java, C, C++, Python, PHP, JavaScript. It is written by developers in
any scripting or high-level language which also contains some lines of comments for a better
understanding of the logic behind the code and for easy modification.

We use any text editor like vi, gedit or notepad to write the source code and save the file in the computer
memory.A file containing C source code known as C source file. We can identify different types of file
by their extension, like any text file has .txt extension. Similarly any C source file is distinguished from
other file by its extension as .c. For example if we are writing a program for addition of two numbers let
call it as add then we have to save it as add.c.

Now we want to execute the source code which is written in high level language, but we cannot directly
execute the source code because system only understand machine code. Before execution the source code
must be converted into executable code (machine code) which is understandable by the system. The
process of translating a source code to a executable code is known as build process.

10

2021-22 Prepared by: Piyali De ( Brainware University, Barasat)


BRAINWARE UNIVERSITY
[CESCM201] CLASS NOTES [Programming for Problem Solving]

Build process contains many sequential steps.

1. Preprocessing:- The first step in the build process is preprocessing. For preprocessing we use a
program called pre-processor. This program takes our source code .c file as input, do some
processing and produces an intermediate code as output. In our case input is add.c and the
intermediate code is add.i.

2. Compilation :- The next step is compilation where a software called compiler translate the
intermediate into lower level code. There are many compilers available for compiling c file. Here we
are using GCC compiler. GCC stands for GNU Compiler Collection. Some compilers takes the
intermediate code and directly produces machine level code. But GCC compilers produces
Assembly code after compilation instead machine level code. Compilers deals with all type of
syntax errors present in the source file.

3. Assemble:- the extension of the assemble code is .s. The program called assembler takes the
assembly code as input and produces object code. Object code has .o or .obj extension. The file
containing the object code is known as Object file.

4. Linking:- The linker lings all object code together and links them with standard libraries to produce
executable code. The executable code has .exe extension. Then we can able to run the executable
code when it it loaded in the main memory by the loader.

Syntax Error :- Every programming language provide some rules for writing programs. The
programmers have follows those rules while writing the program. Syntax Errors occur when
programmers violate the rules of writing the statements of the programming language. During
compilation, if the source code contains syntax error, then the location of the error and the type of the

11

2021-22 Prepared by: Piyali De ( Brainware University, Barasat)


BRAINWARE UNIVERSITY
[CESCM201] CLASS NOTES [Programming for Problem Solving]

error is displayed by the compiler. Then we have to remove the error and recompile the file to get the
object file. Example, misspelling of ‘int’ is a syntax error.

Logical Error: - A program with logical error will not cause the program to terminate the execution but
the generated output is wrong. A logical error occurs due to a fault in the algorithm. The programmer
have to find out the logical error because the compiler will not generate any error message for logical
error.

12

2021-22 Prepared by: Piyali De ( Brainware University, Barasat)

You might also like