Concept of Computer
Concept of Computer
Computer Programming
DR. MADHUSMITA SAHU
ASSOCIATE PROFESSOR
DEPARTMENT OF COMPUTER SCIENCE AND INFORMATION TECHNOLOGY
Topics to be discussed
Computer
Problem Solving
Algorithm
Flowchart
Program and Programming Language
1
04-09-2024
Computer
The term computer is derived from the word compute.
A computer is an electronic device that takes data and instructions as an input from the users,
processes data and provides useful information known as output.
The electronic device is known as hardware and the set of instructions is known as software.
2
04-09-2024
Input Unit
Accepts (or reads) the list of instructions and data from the outside world.
Converts these instructions and data in computer acceptable form.
Supplies the converted instructions and data to the computer system for further processing.
3
04-09-2024
Output Unit
Accepts the results produced by the computer which are in coded form and hence cannot be
easily understood by humans.
Converts these coded results to human acceptable form.
Supplies the converted results to the outside world.
4
04-09-2024
5
04-09-2024
6
04-09-2024
Types of Memory
7
04-09-2024
Input devices
Output Devices
Monitor
Printer
Plotter
Projector
Speaker
Headphones
Light/LED
8
04-09-2024
Problem Solving
Problem solving is an art in itself.
One guiding principle is to break the complex problem into several
comprehensible sub-problems.
The user has to identify the successive operations required for solving each of
these sub-problems.
Once this is successfully completed, a solution to each of the sub-problems is
arrived at.
These solutions are combined to form a solution to the original problem.
9
04-09-2024
10
04-09-2024
11
04-09-2024
Algorithm
An algorithm is a step by step sequence of instructions that give a complete solution to a
particular problem.
The number of instructions in an algorithm is always finite.
Thus, an algorithm is a collection of finite number of instructions arranged in a sequence to
solve a particular problem.
Algorithm is a well-defined procedure that allows a computer to solve a problem.
Coding
The process of conversion of various steps of the algorithm into its
equivalent instruction or instructions in the programming language
that has been chosen for the implementation of the solution is called
coding.
12
04-09-2024
Flowchart
Flowcharts are graphical means of describing a sequence of instructions or operations that are
carried out to perform a certain task.
It is just a pictorial representation of an algorithm.
Flowcharts use symbols that have geometrical shapes to indicate the different operations.
These symbols are connected by lines which indicate the order of execution of the various
activities.
A flowchart is a type of diagram that represents an algorithm, workflow or process, showing
the steps as boxes of various kinds, and their order by connecting them with arrows
Decision symbol Indicate a conditional transfer. It has single Diamond shaped box
entry and two or more exits.
Terminal symbol Used to indicate the entry or exit point of a A flat oval
flowchart
13
04-09-2024
Example 1
Find area of a triangle given three sides.
1. Start
2. Read a, b, c
3. s=(a+b+c)/2
4. area=sqrt(s*(s-a)*(s-b)*(s-c))
5. Print area
6. Stop
Example 2
Find largest of two numbers.
1. Start
2. Read a, b
3. If a>=b then goto step 6
4. Print b
5. goto step 8
6. Print a
7. goto step 8
8. Stop
14
04-09-2024
Example 3
Find sum of first 100 natural numbers.
1. start
2. sum=0
3. i=1
4. if i<=100 then goto 7
5. print sum
6. goto 10
7. sum=sum+i
8. i=i+1
9. goto step 4
10. stop
Pseudocode
Pseudocode is a simple way of writing programming code in English.
Pseudocode is not an actual programming language.
It uses short phrases to write code for programs before you actually create it in a specific
language.
Pseudocode is an artificial and informal language that helps programmers develop algorithms.
Pseudocode is very similar to everyday English.
15
04-09-2024
Example
Write an algorithm to determine a student’s final grade and indicate whether it is passing or
failing.
The final grade is calculated as the average of four marks.
Pseudocode
Input a set of 4 marks
Calculate their average by summing and dividing by 4
if average is below 50
Print “FAIL”
else
Print “PASS”
16
04-09-2024
Algorithm
1. Input M1,M2,M3,M4
2. GRADE (M1+M2+M3+M4)/4
3. if (GRADE < 50) then
Print “FAIL”
else
Print “PASS”
endif
Program
Program is a sequence of instructions in a particular programming language, written to
perform a specified task on a computer.
17
04-09-2024
Programming Language
A language is a system of communication.
A programming language is a means of communication used to communicate between people
and the computer.
The set of symbols used by a particular language is known as the vocabulary of that language.
All computer programming languages have their own vocabulary.
Each symbol of a computer language is used to tell the computer to do a particular job.
The process of writing program instructions for an analysed problem is called coding.
18
04-09-2024
Machine language
It is easily understood by computers, machine languages are almost impossible for humans to
use because they consist entirely of numbers.
For example, an x86/IA-32 processor can execute the following binary instruction as expressed
in machine language:
Binary: 10110000 01100001 (Hexadecimal: 0xb061)
19
04-09-2024
High-level language
High-level languages are used to solve problems and are often described as problem-oriented
languages.
Some High Level Languages are: Ada, Algol, LISP, Java.
Source code
A program written in a high-level language is called source code.
Source code is also called source program.
Computer cannot understand the statements of high-level language.
The source code cannot be executed by computer directly.
It is converted into object code and then executed.
20
04-09-2024
Object code
A program in machine language is called objet code.
It is also called object program or machine code.
Computer understands object code directly.
Translator
Used to convert high-level and low-level languages into machine language.
Types
Compiler
Interpreter
Assembler
21
04-09-2024
Compiler
A translating program that translates the instructions of a high-level language into machine
language.
It's a computer program(s) that transforms source code written in a programming language
into machine language that is the target language which usually has a binary form known as
object code.
It compiles a set of machine language instructions for every program instruction of a high-level
language.
A program written by a programmer in a high-level language is called a source program.
The program generated by a compiler after converting to machine language is called an object
program.
Compiler searches all errors in the code and lists them.
Interpreter
A translating program that translates the instructions of a high-level language into machine
language.
It translates high level instructions into an intermediate form, it translates the code into the
intermediate form line by line an caries out specific actions.
It takes one statement of a high-level language and translates it into a machine instruction
which is immediately executed.
It translates one instruction and the resulting machine code is executed, the next instruction is
translated and the resulting machine code is executed and so on.
Interpreter searches the error statement by statement
22
04-09-2024
Assembler
A translating program that translates the instructions of assembly language into machine
language.
It is a program that takes basic computer instruction(s) and converts then into a pattern of bits
that the computer's processor can use to perform it's basic operations.
The language used to program the assembler is called assembly language.
Loader
A program that loads the object program into memory for execution.
It is the part of an operating system that is responsible for loading programs from executables
(i.e., executable files) into memory, preparing them for execution and then executing them.
23
04-09-2024
Linker
A program that links various libraries and files to the source program.
It is a program that takes one or more objects generated by a compiler and combines them into
a single executable program.
24
04-09-2024
Program Design
Designing is the first step for obtaining solution of a given problem.
Various designing methodologies are:
Top-down design
Bottom-up design
Modular approach
Top-down design
If we look at a problem as a whole, it may seem impossible to solve because it is so complex.
For example, writing a tax computation program.
Complex problems can be solved using top-down design, also known as stepwise refinement.
25
04-09-2024
Bottom up Design
It is the reverse of top-down design.
It starts from the lowest level components to the highest level components.
It first design the basic components and from these basic components the higher level
components are designed.
Modular Approach
It is better to divide a large system into modules.
Module is a well defined part of program.
It is easy to modify a program written with modular approach because changes in one module
don’t affect other modules of program.
Information hiding.
Easy debugging.
26
04-09-2024
Bit/Byte
1 bit = a binary digit 0 or 1
1 nibble=4 bit
1 byte(B)=8 bit
1 kilobyte(KB)=210 B=1024 B
1 megabyte(MB)=1048576 B=220 B=210KB
1 gigabyte(GB)=1073741824B=230B=210MB=220KB
1 terabyte(TB)=1099511627776B= 240B=210GB=220MB
1 petabyte(PB)=1125899906842624B =250B=210TB=220GB
1 exabyte(EB)=1152921504606846976B= 260B=210PB=220TB
1 zettabyte(ZB)=1180591620717411303424B= 270B=210EB=220PB
1 yottabyte(YB)=1208925819614629174706176B= 280B=210ZB=220EB
27