Preview

Selection Struture

Good Essays
Open Document
Open Document
385 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
Selection Struture
The selection structure in computer programming gives the program a couple of passage ways to complete a certain task. It separates the code base on different conditions set forth in the coding. This is presented by giving a conditional expression, in which the computer tests conditions in order to know statements to perform. Programmers give the computer guidelines on how to make the proper decision in order to carryout specific task. Selection structure is broken down into three common structures single alternative, dual alternative and case statement.
Single-alternative selections, take action on just one branch of the decision. The single-alternative selection structure evaluates a condition and executes a block of code if that condition is true. If the condition is false, then the block of code is ignored. An example of a single-alternative selection structure is the if-then statement. if (average_score < 60) cout < < "Failing" < < endl;
Dual-alternative is defined as one action to be taken when the tested condition is true and another action to be taken when it is false. The dual-alternative selection structure evaluates a condition and executes one of two possible passage ways paths. If the condition is true, then one block of code is executed. If the condition is false, the other block of code is executed. An example of a dual-alternative selection structure is the if-then-else statement.
If (average_score < 60) dispay Failing else score
+++++++++++++++++++
>>60 print "Passing" endl;
To make a decision based on the value of a variable we have used the if-then-else statements. If there are multiple values the variable can take on, we have used multiple or nested if-then-else statements. The case selection structure provides multiple alternatives. It inspects a value and chooses the right path of execution that is assigned to that value. For example, a case selection structure could be used to divide the code based

You May Also Find These Documents Helpful

  • Good Essays

    The SELECT statement is the primary means of extracting data from database tables, and allows you to determine exactly which data you want to extract by means of different comparison operators used in the WHERE clause. This includes the use of specific "wild card" characters which allow you to search for character or number patterns within the data. You can also perform mathematical expressions within the SELECT statement to create derived output. The ORDER BY clause allows you to sort the output data in either ascending (the default) or descending order. Lab #5 will explore all of these applications of the SELECT statement.…

    • 1559 Words
    • 7 Pages
    Good Essays
  • Good Essays

    Nt1310 Unit 1 Quiz

    • 1980 Words
    • 8 Pages

    6 . For an unconditional approach to a particular part of a complex PL/SQL block, which of the following control structures can be used?…

    • 1980 Words
    • 8 Pages
    Good Essays
  • Good Essays

    Nt1330 Unit 4

    • 920 Words
    • 4 Pages

    4. Which of the following comparisons does a switch make when deciding whether a new…

    • 920 Words
    • 4 Pages
    Good Essays
  • Satisfactory Essays

    SD1230 Lab 1

    • 239 Words
    • 2 Pages

    2. What type of instruction is used to execute different code based on a condition? -Jumps…

    • 239 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Rjdt Task 2a

    • 1452 Words
    • 6 Pages

    The process for choosing the three alternatives began by identifying the decision to be made. The decision at hand is what to do with the information discovered about the order of whistles going to a school in South America. This is a big decision that will affect the company in each alternative. The next step of the process is listing options possible for the situation, and then studying those options by listing advantages and disadvantages of each. Then the decision was made by choosing the best overall solution for the decision. And lastly the decision was evaluated to determine if the results were what was expected.…

    • 1452 Words
    • 6 Pages
    Satisfactory Essays
  • Powerful Essays

    3. If a cost is identical under each alternative under consideration within a given decision context, the cost is considered:…

    • 946 Words
    • 10 Pages
    Powerful Essays
  • Satisfactory Essays

    Homework Unit 3

    • 354 Words
    • 2 Pages

    1. Statements are execute in order according to the program code. Complex programs can need the help of a decision structure. Statements have to be true to be executed.…

    • 354 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    The three options that the author gives in this article are based on three different outcomes that…

    • 629 Words
    • 3 Pages
    Good Essays
  • Good Essays

    AP US History Quiz Ch10

    • 1854 Words
    • 8 Pages

    CHOICE. MULTIPLE Choose the one alternative that best completes the statement or answers the question.…

    • 1854 Words
    • 8 Pages
    Good Essays
  • Good Essays

    c) Then a nested IF should test if B15 is equal to the shipping option in D41, and if so, then the value in E41 should be used, otherwise the value in E42 should be used.…

    • 724 Words
    • 3 Pages
    Good Essays
  • Satisfactory Essays

    E. Calculate the weighted total points based on the four category points (assignment average, lab points, midterm average, and final exam) and their respective weights (stored in the range B40:B43) in cell Y8. Use the relative and absolute cell references as needed in the formula. The first student’s total weighted score is 90.…

    • 472 Words
    • 2 Pages
    Satisfactory Essays
  • Powerful Essays

    Ethical Paper

    • 886 Words
    • 4 Pages

    What are two alternatives for the scenario? One alternative can be a wild card that you ordinarily may not consider an option because of potential implications. Both should be…

    • 886 Words
    • 4 Pages
    Powerful Essays
  • Good Essays

    6. Conditional expressions used in a While statement have the same components as conditional expression used in what other control construct?…

    • 610 Words
    • 3 Pages
    Good Essays
  • Satisfactory Essays

    The reason I chose the “If-Then-Else” structure is because it seemed to make the most sense for my program and it didn’t appear to be too complicated a structure to master. Even though this structure may not be included as part of my final proposal paper, I thought it would be good to work with and verify if I could somehow make it work. The program I’ll ultimately be creating is one where seasonal stats will be entered in by an assistant coach, for athletes on any given basketball team. Through this they will be able to determine a players overall field goal average, free throw percentage, rebound average, etc. However, for now, I’ve decided to simply use an If-Then-Else structure that displays a friendly output message of what the user might see if he/she entered their “field goals attempted” value and “field goals made” value. The…

    • 537 Words
    • 16 Pages
    Satisfactory Essays
  • Powerful Essays

    Internal Selection

    • 2470 Words
    • 10 Pages

    -One important difference pertains to content: usually greater depth and relevance to the data available on internal candidates…

    • 2470 Words
    • 10 Pages
    Powerful Essays

Related Topics