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, 04.07.2019 08:10
Which of the following is an easy way to remember the modified ā€œxā€ tire rotation? a. nondrive wheels straight, cross the drive wheels b. drive wheels straight, cross the nondrive wheels c. drive wheels crossed, nondrive wheels straight d. drive wheels crossed, nondrive wheels crossed
Answers: 1
question
Engineering, 04.07.2019 18:10
Steel is coated with a thin layer of ceramic to protect against corrosion. what do you expect to happen to the coating when the temperature of the steel is increased significantly? explain.
Answers: 1
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
Condition monitoring is a major component of. (clo4) a)- predictive maintenance. b)-preventive maintenance c)-proactive maintenance d)-reactive maintenance.
Answers: 1
You know the right answer?
Write a program that reads in non-negative integers and stores and displays distinct numbers (i. e.,...
Questions
question
English, 23.11.2020 04:10
question
Computers and Technology, 23.11.2020 04:10
question
Mathematics, 23.11.2020 04:10
question
Mathematics, 23.11.2020 04:10
Questions on the website: 13722363