subject
Engineering, 15.04.2020 15:35 jess7kids98

Write a program that reads in non-negative integers and stores and displays distinct numbers (i. e., if a number appears multiple times, it is stored and displayed only once). Your program should allow up to 1000 distinct numbers to be stored and displayed. Use the following algorithm (this is required!): Read each number and store it in an array if it is new. If the number is already in the array, ignore it. The user will indicate that they are done entering numbers by entering a negative number. Here is a sample run:

Enter a non-negative integer (negative to quit): 1
Enter a non-negative integer (negative to quit): 2
Enter a non-negative integer (negative to quit): 3
Enter a non-negative integer (negative to quit): 2
Enter a non-negative integer (negative to quit): 1
Enter a non-negative integer (negative to quit): 6
Enter a non-negative integer (negative to quit): 3
Enter a non-negative integer (negative to quit): 4
Enter a non-negative integer (negative to quit): 5
Enter a non-negative integer (negative to quit): 2
Enter a non-negative integer (negative to quit): -4
You entered:
1 2 3 6 4 5
To get credit for this assignment you must use appropriate decomposition! You should have a function to read the numbers and a function to print the resulting array. The function that reads the numbers should call an additional function that returns a bool value indicating whether a number is already in the array. At the conclusion of the call to the function that reads the numbers, the array MUST contain only distinct numbers.

Additionally, you must not sort the array. The numbers must appear in the same order in which they were typed.

ansver
Answers: 2

Another question on Engineering

question
Engineering, 03.07.2019 15:10
Apiston-cylinder with a volume of 0.25 m3 holds 1 kg of air (r 0.287 k/kgk) at a temperature of 100 c. heat transfer to the cylinder causes an isothermal expansion of the piston until the volume triples. how much heat is added to the piston-cylinder?
Answers: 3
question
Engineering, 04.07.2019 18:10
An air conditioning system consist of a 5 cm diameter pipe, operating at a pressure of 200 kpa. the air initially enters the pipe at 15°c with a velocity of 20 m/s and relative humidity of 80%. if the heat supply throughout the process is 960 w, determine the relative humidity and the temperature at the outlet
Answers: 3
question
Engineering, 04.07.2019 18:10
Afour cylinder four-stroke in-line engine has a stroke of 160mm, connecting rod length of 150mm, a reciprocating mass of 3kg and its firing order is 1-3-4-2. the spacing between cylinders is 100mm. i. show that the engine is in balance with regard to the primary inertia forces and primary 3. a and secondary inertia couples. li determine the out of balance secondary inertia force ii. propose ways of balancing this out of balance force and discuss the challenges that will arise
Answers: 3
question
Engineering, 04.07.2019 18:10
Calculate the bore of a cylinder that has a stroke of 18 inches and an extension time of 6 seconds at a flow rate of 4 gal/min.
Answers: 3
You know the right answer?
Write a program that reads in non-negative integers and stores and displays distinct numbers (i. e.,...
Questions
question
Business, 17.11.2020 21:10
question
History, 17.11.2020 21:10
question
Mathematics, 17.11.2020 21:10
question
Biology, 17.11.2020 21:10
question
Mathematics, 17.11.2020 21:10
question
Mathematics, 17.11.2020 21:10
question
Mathematics, 17.11.2020 21:10
question
Biology, 17.11.2020 21:10
Questions on the website: 13722363