PTS 1 REF 254 TOP Critical Thinking 9 What is an advantage of using an array to

Pts 1 ref 254 top critical thinking 9 what is an

This preview shows page 6 - 7 out of 7 pages.

PTS:1REF:254TOP:Critical Thinking
9.What is an advantage of using an array to match a value in a range of values?ANS:When using an array to store range limits, you use a loop to make a series of comparisons that would otherwise require many separate decisions. The program that determines customer discount rates is written using fewer instructions than would be required if you did not use an array, and modifications to your method will be easier to make in the future.PTS:1REF:257TOP:Critical Thinking10.What happens if a subscript value is negative or higher than the number of elements in an array?ANS:Some programming languages will stop execution of the program and issue an error message. Other programming languages will not issue an error message but will access a value in a memory location that is outside the area occupied by the array. That area might contain garbage, or worse, it accidentallymight contain the name of an incorrect month. Either way, a logical error occurs.PTS:1REF:259-260TOP:Critical Thinking

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture