Computers - Ch 4

Created by anishahegde

algorithm
it is a set of sequential steps to solve systematically.

1/15

TermDefinition
algorithm
it is a set of sequential steps to solve systematically.
characteristics of an algorithm
1. Well-defined steps 2. Step-by-step instructions that are free of programming codes 3. Written in simple language 4. The desired output must be obtained after the algorithm terminates
algorithm to find sum and avg of 2 numbers
step 1: start Step 2: input 2 numbers, A and B Step 3: calculate sum (A+B) Step 4: calculate average (A+B)/2 step 5: Print the sum and average Step 6: stop
algorithm to compare 2 numbers and determine the greater value
step 1: start Step 2: input two numbers, A and B Step 3: check whether A is equal to B and go to step 4. Else, go to step 5 step 4: print "A is equal to B" and go to step 8 step 5: compare A and B. If A is greater, go to step 6. Else, go to step 7. step 6: Print "A is greater than B" and go to step 8. step 7: print "B is greater than A" step 8: stop
flowchart
It diagrammatically represents the steps in the algorithm. It makes the program easier to understand.
characteristics of a flowchart
1. The symbols are used accordingly based on their function. 2. it must flow in a logical order. 3. it must have a clear start and end. 4. it must have arrows that indicate the flow of instruction.
shape of start/stop box
oval
start / stop box
used in beginning and end of flowchart. it is also called the terminal box.
shape of input/output box
parallelogram
input/ output box
it is used to accept input or display output of the program.
shape of processing box
rectangle
processing box
Used for writing processing instructions and performing calculations.
shape of decision box
diamond
decision box
it is used for checking or applying any condition in the program. it has one entry point and 2 exit points, one of which shows true and other shows false.
flow lines
arrows used to indicate the flow of instructions.