Pt1420 Intor to Programming Unit 7 Homework

1307 Words6 Pages
Unit 7 Assignment 1: Homework * Short Answer Review Questions 1-5, starting on page 213 1. Why should you indent the statements in the body of a loop? Indenting the statements in the body of a loop sets the statements apart from the rest of the code making it easier to read and debug. 2. Describe the difference between pretest loops and posttest loops. Pretest loops evaluate a condition before executing the code within the loop. Pretest loops also may have conditions in which the loop never executes. Posttest loops evaluate the condition after the code contained within the loop executes. This type of loop always runs at least 1 iteration of the loop. 3. What is a condition- controlled loop? A condition-controlled loop is a type of loop that uses a True/False condition to control the number of times that it repeats. While the condition being tested is True, the loop continues to run. 4. What is a count- controlled loop? A count-controlled loop is a type of loop that repeats a specific number of times. This type of loop usually consists of an increment/decrement counter to control the number of times that the loops is run. 5. What three actions do count- controlled loops typically perform using the counter variable? The three actions count-controlled loops typically perform when using the counter variable are Initialization, Test, and Increment. Initialization is done before the loop begins and the variable is initialized to a starting value. The loop tests the counter variable by comparing it to a maximum value. Increment refers to the increase in a variables value. * Algorithm Workbench Review Questions 1, 2, 7, and 8, starting on page 213 1. Design a While loop that lets the user enter a number. The number should be multiplied by 10, and the result stored in a variable named product. The loop should iterate as long as product

More about Pt1420 Intor to Programming Unit 7 Homework

Open Document