Download presentation
Presentation is loading. Please wait.
Published byRebecca Warren Modified over 8 years ago
2
WHAT IS THIS? Clue…it’s a drink
3
SIMPLE SEQUENCE CONTROL STRUCTURE Introduction A computer is an extremely powerful, fast machine. In less than a second, it can perform difficult calculations that otherwise would take days, months, or years to perform. Yet, a computer has no magical powers; it is only a tool. It cannot devise a plan or decide to act. It can only do what it is told. We can direct the computer to do what we want by specifying our needs in a discrete step-by-step manner to solve a problem, called an algorithm. A computer cannot act independently; it has not intelligence of its own. For this reason, any algorithm that we use to direct it must be set up to identify all aspects of a processing situation and to present, in detail, all steps to be performed.
4
SIMPLE SEQUENCE CONTROL STRUCTURE Introduction The algorithm must: 1.Use only operations from a given set of basic operations, such as: + which means to add - which means to subtract *which means to multiply /which means to divide and give the dividend MODwhich means to divide and give the remainder 2. Produce the problem solution, or answer, in a finite number of such operations, because each operation performed by a computer takes a certain amount of time.
5
SIMPLE SEQUENCE CONTROL STRUCTURE Introduction The term algorithm may be new to you, but most of us use numerous algorithm daily. For example, we adopt routine procedures, or algorithms, for getting up in the morning, fixing our favourite meal, going to school, and so on. Example: Consider the following Wake up algorithm flowchart Start GET OUT OF BED EAT BREAKFAST BRUSH TEETH TAKE SHOWER GET DRESSED Stop This is connector; to be used when you run out of space
6
SIMPLE SEQUENCE CONTROL STRUCTURE
8
ABOUT ALGORITHM FLOWCHART What is a flowchart? A flowchart is a visual representation of a flow of data. It can be used to outline a process or a solution to a problem, whether it is simple or complex. For beginners in programming, it is vital to learn flowcharting to understand the basic logic behind a program. After a flowchart is created, it can be implemented (coded) in any language! Example of Simple Sequencing using FLOWCHART
9
ABOUT ALGORITHM FLOWCHART The following symbols are used to create a flowchart:
10
EXAMPLE of SIMPLE SEQUENCING Problem: Write a structured algorithm that prompts the user to two numbers. The algorithm should calculate and print the sum of the two numbers. NOTE: You have already been taught how to input and output. In programming, a process normally takes place. You need to determine the process or processes, and then determine where to place it in the algorithm. In this example, only one process is necessary – to sum to values. You will need to accept the values before you can find their sum. After finding the sum you will need to store it in a variable.
11
EXAMPLE of SIMPLE SEQUENCING Problem: Write a structured algorithm that prompts the user to two numbers. The algorithm should calculate and print the sum of the two numbers. Psuedocode START PRINT “Enter two numbers” READ num1, num2 ans = num1 + num2 PRINT “The sum is”, ans STOP The beginning of the program The end of the program Tells the user what you want them to do. When the user enters the two values, you will READ it from them and the store the values in two separate variables Calculate the sum, and then store it in a variable called ans Outputs the sum of the two values
12
EXAMPLE of SIMPLE SEQUENCING Problem: Write a structured algorithm that prompts the user to two numbers. The algorithm should calculate and print the sum of the two numbers. Psuedocode START PRINT “Enter two numbers” READ num1, num2 ans = num1 + num2 PRINT “The sum is”, ans STOP FLOWCHART START PRINT “Enter two numbers” READ num1, num2 ans = num1 + num2 PRINT “The sum is”, sum STOP
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.