1 / 12

Simple Sequence Control Structure

Simple Sequence Control Structure. Brain Teaser. WHAT IS THIS? Clue…it’s a drink. SIMPLE SEQUENCE CONTROL STRUCTURE. Introduction

afountain
Télécharger la présentation

Simple Sequence Control Structure

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Simple Sequence Control Structure

  2. Brain Teaser 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: • 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 • MOD which 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 algorithmflowchart Start TAKE SHOWER GET OUT OF BED GET DRESSED EAT BREAKFAST BRUSH TEETH Stop This is connector; to be used when you run out of space

  6. SIMPLE SEQUENCE CONTROL STRUCTURE Class Activity Write out the steps involved in making a quick box Macaroni and Cheese.

  7. SIMPLE SEQUENCE CONTROL STRUCTURE Class Activity Write out the steps involved in the animation below.

  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. You have 2 minutes to try this question on your own.

  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. The beginning of the program When the user enters the two values, you will READ it from them and the store the values in two separate variables Psuedocode START PRINT “Enter two numbers” READ num1, num2 ans = num1 + num2 PRINT “The sum is”, ans STOP Tells the user what you want them to do. Calculate the sum, and then store it in a variable called ans Outputs the sum of the two values The end of the program

  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

More Related