Download presentation
Presentation is loading. Please wait.
Published bySir Campbell Modified over 5 years ago
1
Click to add Text Computers & Instructions
2
Computers are given instructions in the form of computer programs that are created through the development of algorithms.
3
The role of a programmer in giving the computer instruction To create instructions that the computer needs to follow in order for it to complete a specific task.
5
What is an algorithm? A sequence of precise instructions for solving a problem in a finite amount of time. It can be represented in two ways: Pseudocode – the use of English-like statements to represent an algorithm. Flowchart – graphical representation of an algorithm.
6
Flowchart and Pseudocode Examples
9
Attributes of an algorithm Algorithms must be: precise unambiguous (not having two or more possible answers) finite (terminate after a finite number of steps) in a logical sequence
10
Control Structures It is possible to write any program using only three basic control structures: 1.Sequence: the straightforward execution of one processing step after another. 2.Selection: the presentation of a condition, and the choice between two or more actions, depending on whether the condition is true or false. 3.Repetition: the presentation of a set of instructions to be performed repeatedly, as long as a condition is true.
11
Three(3) main Control Structures
12
The two major phases in problem-solving on the computer Problem-Solving Phase Implementation Phase
13
The Problem-Solving Phase Define the problem Find a solution to the problem Evaluate the alternative solutions Represent the most efficient solution as an algorithm Test the algorithm for correctness
14
The Implementation Phase Translate the algorithm into specific programming language Execute the program on the computer Maintain the program
15
Breaking up a problem into three key components What is given (inputs) The expected results (outputs) The tasks that must be performed (processing)
16
Class Activity Break up the following problem into the three key components input, processing & output read two numbers, add them together and display their total
17
Class Activity What is given (inputs) –two numbers The expected results (outputs) –Sum of the two numbers The tasks that must be performed (processing) –Get the two numbers –Calculate the sum of the two numbers –Display the sum of the two numbers
18
Homework Break up the following problem into the three key components input, processing & output A box can hold one and a half dozen cans of tomatoes. Read the number of boxes and the price of a can of tomatoes; calculate and print the total cost of all the cans of tomatoes.
19
Homework Solution INPUT –NumberOfBoxes –Price OUTPUT –TotalCost PROCESSING 1.Read NumberOfBoxes and Price 2.Calculate the TotalCost of all the cans of tomates 3.Print TotalCost
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.