Inro to Pc Programming Unit 5 Assignment 1 Homework

1059 Words5 Pages
Unit 5 Assignment 1: Homework Short Answer 1-7 p.158 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 structure would be the most straightforward to use? The case structure lets the value of a variable or an expression determine which path of execution the program will take. 4) Briefly describe how the AND operator works. The AND operator takes two Boolean expressions as operands and creates a compound Boolean expression that is True only when both sub-expressions are true. The following is an example of an If-Then statement that uses the AND operator: If temperature < 20 AND minutes > 12 Then Display “The temperature is in the danger zone.” End If 5) Briefly describe how the OR operator works. The OR operator takes two Boolean expressions as operands and creates a compound Boolean expression that is true when either of the sub-expressions is true. The following is an example of an If-Then statement that uses the OR operator: If temperature < 20 OR temperature > 100 Then Display “The temperature is in the danger zone.” End If 6) When determining whether a number is inside a range, which logical

More about Inro to Pc Programming Unit 5 Assignment 1 Homework

Open Document