Docsity

Solving a Problem with a Single-Subscripted Array: Reading Unique Numbers, Lecture notes of Computer Programming

Toggle sidebar
bg1
Question 1
Use a single-subscripted array to solve the
following problem. Read in 20 numbers, each of
which is between 10 to 100, inclusive. As each
number is read, print it only if it is not a
duplicate of a number already read. Provide for the
“worst case” in which all 20 numbers are different.
Use the smallest possible array to solve this
problem.

Partial preview of the text

Download Solving a Problem with a Single-Subscripted Array: Reading Unique Numbers and more Lecture notes Computer Programming in PDF only on Docsity!

Question 1

Use a single-subscripted array to solve the following problem. Read in 20 numbers, each of which is between 10 to 100, inclusive. As each number is read, print it only if it is not a duplicate of a number already read. Provide for the “worst case” in which all 20 numbers are different. Use the smallest possible array to solve this problem.