jagomart
digital resources
picture1_Programming Pdf 182640 | 7 Programming Selection


 135x       Filetype PDF       File size 0.13 MB       Source: rainford.org.uk


File: Programming Pdf 182640 | 7 Programming Selection
selection in programming when designing programs there are often points where a decision must be made this decision is known as selection and is implemented in programming using if statements ...

icon picture PDF Filetype PDF | Posted on 31 Jan 2023 | 2 years ago
Partial capture of text on file.
                    Selection in programming 
                    When designing programs, there are often points where a decision must be made. This 
                    decision is known as selection, and is implemented in programming using IF statements. 
                    Selection  
                    An algorithm is a plan, a set of step-by-step instructions designed to solve a problem. 
                    When designing algorithms there are three basic building blocks (constructs) that can be 
                    used: 
                 •    sequencing 
                 •    selection 
                 •    iteration 
                    Algorithms are used to help design programs that perform particular tasks. 
                    What is selection? 
                    An explanation of selection, as used in algorithms and programming 
                    Selection is a decision or question. 
                    At some point, a program may need to ask a question because it has reached a step 
                    where one or more options are available. Depending on the answer given, the program 
                    will follow a certain step and ignore the others. 
                                                                                                              
       Why is selection important? 
       Selection allows there to be more than one path through a program. 
       Many solutions feature several choices or decisions. These decisions lead to different 
       paths through the program. These paths represent the result of making a choice. 
       Without selection it would not be possible to include different paths in programs, and the 
       solutions we create would not be realistic. 
       Selection in programming 
       Once an algorithm has been designed and perfected, it must be translated – or 
       programmed – into code that a computer can read. 
       We create programs to implement algorithms. Algorithms consist of steps, where 
       programs consist of statements. 
       Selection is implemented in programming using IF statements. 
       IF statements 
       Programs consist of a set of instructions that are carried out one after another. 
       Sometimes there may be more than one path (or set of steps) that can be followed. At 
       this point, a decision needs to be made. This decision is known as selection. 
       For example, this simple algorithm prints out a message depending on how old you are: 
      1.  Ask how old you are 
      2.  IF you are 70 or older, say “You are aged to perfection!” 
       The selection comes in step 2. If you are aged 70 or over, one message is displayed. 
       As a flowchart, the algorithm would look like this:  
       In programming, selection is implemented using an IF statement 
                    IF...ELSE 
                    In programming, selection is usually represented by the statements IF and ELSE: 
                 •    IF represents the question 
                 •    ELSE points to what to do if the answer to the question is false 
                    For example, this simple algorithm prints out a different message depending on how old 
                    you are. Using IF and ELSE, the steps are: 
                 •    Ask how old you are 
                 •    IF you are 70 or older, say “You are aged to perfection!” 
                 •    ELSE say “You are a spring chicken!” 
                    If this algorithm is tried using 75 as our age, the answer to the question at step 2 is true, 
                    so the algorithm tells us to say “You are aged to perfection!” 
                    If the algorithm is tried using 15 as our age, the answer to the question at step 2 is false, 
                    so the algorithm tells us to say “You are a spring chicken!” 
                    Two different paths are followed according to the answer given to a particular question. 
                    The flowchart to illustrate this algorithm is: 
                                                                                                                                                     
The words contained in this file might help you see if this file matches what you are looking for:

...Selection in programming when designing programs there are often points where a decision must be made this is known as and implemented using if statements an algorithm plan set of step by instructions designed to solve problem algorithms three basic building blocks constructs that can used sequencing iteration help design perform particular tasks what explanation or question at some point program may need ask because it has reached one more options available depending on the answer given will follow certain ignore others why important allows than path through many solutions feature several choices decisions these lead different paths represent result making choice without would not possible include we create realistic once been perfected translated programmed into code computer read implement consist steps carried out after another sometimes followed needs for example simple prints message how old you older say aged perfection comes over displayed flowchart look like statement else usu...

no reviews yet
Please Login to review.