Pt1420 Unit 8 Homework Online

Answer Review Questions 6 – 10: Pg 213 6. What is an infinite loop? Write the code for an infinite loop. An infinite loop is a sequence of instructions in a computer program which loops without ending. Set A = 1 While A < = 10 Display A End While 7. A For loop looks like what other loop in a flowchart? Looks like a while loop. 8. Why is it critical that accumulator variables are properly initialized? An accumulator is used to keep a running total of numbers. In a loop, a value is added to the current value of the accumulator. If it is not properly initialized, it will not contain the correct total. 9. What is the advantage of using a sentinel? When a program reads sa sentinel value, it knows it has reached the end of the list so the loop will stop. 10. Why must the value chosen for use as a sentinel be carefully selected? So it can’t be mistaken as a regular value in the list. Workbench Review Questions 3 ,4, 9 ,10 :Pg 213

IT 104 Unit 8 Assignment 1 Short Answer: 6. What is an infinite loop? Write the code for an infinite loop. An infinite loop continues to repeat itself until the program is interrupted. The code for an infinite loop, looks as follows: While keepgoing == “y” 7. A For loop looks like what other loop in a flowchart? It looks like the while loop. 8. Why is it critical that accumulator variables are properly initialized? Accumulator variables should be properly initialized to ensure it does not contain garbage. 9. What is the advantage of using a sentinel? When processing a long list of values with a loop it automatically marks the end of the list. 10. Why must the value chosen for use as a sentinel be carefully selected? A sentinel value must be unique as not to be mistaken as a regular value in the list. Algorithm Workbench: 3. Design a for loop that displays the following set of numbers: 0, 10, 20, 30, 40, 50 … 1000. Declare Integer MAX_VALUE = 1000

0 comments

Leave a Reply

Your email address will not be published. Required fields are marked *