Pt1420 Unit 5 Assignment 1

963 Words4 Pages
Short Answer 1. Explain what is meant by the term “conditionally executed”. Conditionally executed is called a single alternative decision structure because it provides only one alternative path of execution. The action is conditionally executed because it is performed only when a certain condition is true. 2. You need to test a condition and then execute one set of statements if the condition is true. If the condition is false, you need to execute a different set of statements. What structure will you use? I will use the “If” statement because it is a dual alternative decision structure. 3. If you need to a test the value of a variable and use that value to determine which statement or set of statements to execute, which…show more content…
If x > 100 y = 20 z = 40 End If 2. Design an If-Then statement (or a flowchart with a single alternative decision structure) that assigns 0 to the variable b and assigns 1 to the variable c if the variable is a less than 10. If a < 10 Then b = 0 c = 1 End If 3. Design an If-Then-Else statement (or a flowchart with a dual alternative decision structure) that assigns 0 to the variable b if the variable a is less than 10. Otherwise, it should assign 99 to the variable b. If a < 10 b = 0 Else If b = 99 End If 4. The following pseudo code contains several nested If-Then-Else statements. Unfortunately, it was written without proper alignment and indentation. Rewrite the code and use the proper conventions of alignment and indentation. If score < 60 Then Display “Your grade is F.” Else If score < 70 Then Display “Your grade is D.” Else If score < 80 Then Display “Your grade is C.” Else If score < 90 Then Display “Your grade is B.” Else Display ‘Your grade is A.” End If End If End If End If 5. Design nested decision structures that perform the following: If

More about Pt1420 Unit 5 Assignment 1

Open Document