Algorithm and Flowchart
Algorithm and Flowchart
• Speed:
• Computers are much faster to perform
mathematical calculations than human. The
computer is capable of performing millions
of tasks per second.
• Reliability:
• Today every major industry and companies
in the world have full confidence in their
computers, and their entire business is
running from computers.
CHARACTERISTICS OF A COMPUTER
• Accuracy:
• A computer is very accurate. It does not make any kind of mistake in calculating. Sometimes we get
some error but these are because of the mistake performed by us.
• Deligence:
• A person gets tired of doing some work in a few hours and a computer has the ability to do any
work continuously for many hours, days, months.
• Memory:
• Computer systems have a very large capacity to store any type of data. A computer can store and
resell any information due to its storage capacity.
• Versatility:
• Its means is that the computer is capable of working in almost every field. A computer system is
multitasking so that you can do two tasks very easily at the same time.
• Automatic:
• A computer is an automatic machine because once started on a job they carry on until the job is
finished without any human assistance
BASIC ORGANISATION OF COMPUTER
• Input Unit:
• An input device is a hardware or peripheral device used to
send data to a computer. An input device allows users to
communicate and feed instructions and data to computers for
processing, display, storage and/or transmission.
• Some of the most popularly used input devices are:
• Mouse
• Light Pen
• Touch Screen
• Keyboard
• Scanner
• OCR and MICR
• Bar Code Reader
• Joy Stick etc.
• Output Unit:
• The processed data is displayed in the form of result through the output device. Some of the most
popularly used Output devices are:
• Visual Display Unit (Monitor)
• Printer: Dot Matrix, Line Printers, Ink-jet, Laser Printer
• Plotters etc.
• Central Processing Unit:
• The Central Processing Unit (CPU) is known as the heart of the computer which takes control of the
entire processing system of a computer.
• It performs the basic arithmetical, logical, and input/output operations of a computer system.
• The part of a computer that interprets and carries out instructions.
• It also transfers information to and from other components, such as a disk drive or the keyboard.
•
BASIC ORGANISATION OF COMPUTER
• Control Unit:
•
• The control unit coordinates the activities of all the other units and in the system.
• Its main functions are to control the transfer of data and information between various
units and to initiate appropriate actions by the arithmetic-logic unit.
• The control unit fetches instructions from the memory, decodes them, and directs
them to various units to perform the on specified tasks.
BASIC ORGANISATION OF COMPUTER
• Memory Unit:
• Computer memory is divided into two types: Primary memory & Secondary memory
• Primary Memory
• The Primary memory is also called Main memory, is used to store data during processing. Once the
CPU has carried out an instruction, it needs the result to be stored. This storage space is provided by
the computer’s memory.
• Primary memory: Random Access Memory (RAM) and Read Only Memory (ROM).
• RAM : RAM is a volatile memory, which means that the stored information is lost when the power
is switched off used to read and write data in RAM
• ROM: We can only read the data from ROM and you cannot write anything into it and the data is
permanent. ROM is a non - volatile memory
•
BASIC ORGANISATION OF COMPUTER
• Secondary Memory
• The data stored in it is permanent.
• Data can be deleted if necessary.
• It is cheaper than primary memory.
• It has high storage capacity.
• There are different kinds of secondary storage devices available. Few of them are :
• Floppy Disk
• Fixed or Hard Disk
• Optical Disk like: CD (Compact Disk) DVD (Digital Versatile Disk)
• Magnetic Tape Drive
BASIC ORGANISATION OF COMPUTER
ROM serves as permanent data storage RAM can serve as temporary data
storage
APPLICATION OF COMPUTERS IN VARIOUS
FIELDS OF ENGINEERING
✔ 3D Modelling and Animation
✔ Robotics
✔ Automated Car Modelling
✔ Mobile App Development
✔ Web Development
✔ Gaming
✔ User Interface design for Aerospace Applications
✔ Ship Building
✔ Architecture
PROBLEM SOLVING
EVALUATE EXPLORE
SELECT ALTERNATIVES
SOLVING A PROBLEM TO ENGAGE A EVENING
• Identify Alternatives:
•Watch Television
•Invite friends over
•Play games
•Go to movie
•Go to amusement park
•List is complete only when u think of no more alternatives
SOLVING A PROBLEM TO ENGAGE A EVENING
03 Pseudocode
Flowchart 02
01 Algorithm
Algorithms
26
Algorithms
Algorithm
Set of rules to obtain the
Input expected output from the KEYS
Output
given input
Characteristics of Algorithm
Clear and
Unambiguous
02 Terminate Ultimately
04
Criteria for Deciding Successful Algorithms
Accuracy
Expected Outcome
1
Consistency
Must produce the same
Successful result each time it is run
Algorithms
2
Efficiency
3 Must solve the problem in
the shortest possible time
Steps involved in algorithm development
Possessing Identification of
Effectiveness 06. 01. input
Processing Identification of
Finiteness 05. 6 Steps 02. output
Sequence
01
Selection
02
Iteration 03
Keywords used in developing algorithms
STAGE KEYWORDS EXAMPLE
Arithmetic operation add, subtract, multiply and divide Add mark1 and mark2
KEYS
Selection Method
Write an algorithm to accept name and mark. If the mark is greater than or equal to 50
display "PASS" otherwise "FAIL".
Step 1: INPUT the name # input stage
Step 2: INPUT the mark # input stage
Step 3: CHECK IF mark is greater than or equal to 50, if it is TRUE then goto
Step 4 Otherwise goto Step 5 # process stage
Step 4: OUTPUT: Result is PASS goto Step 6 # output stage 1
Step 5: OUTPUT: Result is FAIL # output stage 2 KEYS
Step 6: End
Iteration Method
Write an algorithm to accept name and mark of 5 students. If the mark is greater than or
equal to 50 display "PASS" otherwise "FAIL".
Input
• Customer name
• Customer ID
• Price of an item (price)
• Quantity of the item (qty)
• Tax Percent (tax)
• Discount Percent (dis)
Calculate
• gross=price+(price*(tax/100))
• netamt=qty*(gross-(gross*(dis/100)))
Output
Input
• Customer name
• Customer ID
• Price of an item (price)
• Quantity of the item (qty)
• Tax Percent (tax)
• Discount Percent (dis)
Calculate
• gross=price+(price*(tax/100))
• netamt=qty*(gross-(gross*(dis/100))) ---->Applied when qty>=5
• netamt=qty*gross---> Applied when qty<5
Output
Input
• Customer name
• Customer ID
• Price of an item (price)
• Quantity of the item (qty)
• Tax Percent (tax)
• Discount Percent (dis)
Calculate
• gross=price+(price*(tax/100))
• netamt=qty*(gross-(gross*(dis/100))) ---->Applied when qty>=5
• netamt=qty*gross---> Applied when qty<5
Output
52
• Net Amount (netamt)
FLOWCHARTS
DIAGRAMATIC REPRESENTATION FOR
LOGIC BUILDING
FLOWCHART
IMPORTANCE
Diagrammatic representation of an
algorithm.
Diamond Circle
Arrow Lines
FLOWCHART NOTATIONS
• 10 * 100
Display GrossPay
• 1000
• Stop STOP
START
Read Days
TERMINALS
Display “How
Represented by Rounded Rectangles much do you get
paid per Day?”
Multiply Days by
START END PayRate. Store
result in GrossPay.
Display GrossPay
STOP
START
Read Days
INPUT / OUTPUT OPERATIONS
Display “How
Represented by Parallelograms much do you get
paid per Day?”
Multiply Days by
PayRate. Store
Display “How many result in GrossPay.
Days did you work?” Read Days
Display GrossPay
STOP
START
Read Days
PROCESSES
Display “How
Represented by Rectangles much do you get
paid per Day?”
READ
name
Steps are in Sequential Order
READ
rollno
There are no Alternate paths
PRINT name,
Simple Example rollno
We need to develop a system which
reads Name, Roll number of one student
and displays it. Stop
Start
SELECTION Enter
Dept
Steps are not executed in Sequence
CSE?
We have Alternate paths. Path are chosen NO
based on the decision YES
rollno=1
Terminal
Decision
(start / stop)
Connector
Process Input/Output
REVIEW
What type of Structure is this?
True
False
Iterative
REVIEW
What type of Structure is this?
Sequential
REVIEW
What type of Structure is this?
Selection
EXAMPLES
Lets Have a Look
Sita went to a shop and purchased a
saree and a handbag. Help the
shopkeeper to find how much she is
supposed to pay.
Ramu is a shopkeeper. At the
end of the day he calculating
his expenses of that day. If his
income is greater than his
expenses(cost) he will have
some profit. Otherwise he will
end up with some loss. Display
his profit / loss amount.
SOLVE IT!
Lets Try
Number=8
Start
Enter
Number=7
Number
NO
Number%2==0 Print odd
number
YES
Print even
number
Stop
Number=8
even
number
Number=7
odd
number
If A = 20
B = 30
C = 50
50
Guess the Output??
3
5
7
Guess the Output??
3
6
9
Guess the Output??
3
Guess the Output??
7
Guess the Output??
0 8 16
32 40
96