1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
sleet_krkn [62]
3 years ago
15

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
Computers and Technology
1 answer:
slavikrds [6]3 years ago
4 0

Answer:

See explaination

Explanation:

#include <iostream>

using namespace std;

#define MAX 1005

bool already_present(int data[MAX], int input, int size)

{

int i;

for(i=0;i<size;i++)

if(data[i] == input)

return true;

return false;

}

int read_stdin(int data[MAX])

{

int input;

int size=0;

while(true)

{

cout<<"Enter a non-negative integer (negative to quit): ";

cin>>input;

if(input<0)

break;

if(!already_present(data,input,size))

data[size++] = input;

}

return size;

}

void print_stdout(int data[MAX],int size)

{

int i;

cout<<"You entered\n";

for(i=0;i<size;i++)

cout<<data[i]<<" ";

cout<<endl;

}

int main()

{

int data[MAX],size;

size = read_stdin(data);

print_stdout(data,size);

return 1;

}

You might be interested in
A business that subscribes to a specific computing model has its entire system fully functional within a short time. What benefi
defon

Its quick development

Quick deployment: When a business opts for cloud computing and subscribes to a specific model, its entire system can be fully functional within a short time—even within a few minutes. The amount of time depends on the kind of technology and the business’s computing needs.


7 0
3 years ago
In the classroom settting,listeners can best help reduce speaker presentation anxiety by______
Anuta_ua [19.1K]

speaker ?

notify me if wrong i must know.

3 0
3 years ago
What do you understand by the term polysome?​
jasenka [17]

Answer:

A polyribosome (or polysome or ergasome) is a group of ribosomes bound to an mRNA molecule like “beads” on a “thread”. It consists of a complex of an mRNA molecule and two or more ribosomes that act to translate mRNA instructions into polypeptides.

6 0
3 years ago
Write a python program to accept a number and check whether it is divisible by 4 or not​
Alenkasestr [34]

Answer:

number = int(input("Enter number: "))

if (number % 4):

 print("{} is not divisible by 4".format(number))

else:

 print("{} is divisible by 4".format(number))

Explanation:

If the %4 operation returns a non-zero number, there is a remainder and thus the number is not divisable by 4.

5 0
3 years ago
Circuit pruning occurs only before puberty.<br> O True<br> O False
jok3333 [9.3K]

Answer:

False

Explanation:

7 0
3 years ago
Read 2 more answers
Other questions:
  • Arpanet was developed by the united states so that there was a communication network that would survive a nuclear war. True or F
    11·1 answer
  • _______ Originally , the art of maganing engines; in its modern and extended sense
    7·1 answer
  • Suction cup-type headlamp aiming equipment may be used on:
    11·1 answer
  • Which of the following ways is NOT one of the ways that the census is
    5·1 answer
  • On the 80x86 CPU, the ESP register keeps track of the value on the top of the runtime stack.
    11·1 answer
  • Which element is included in the shot breakdown storyboard? Which element is included in the shot breakdown storyboard?
    8·1 answer
  • Write a complete program in Assembly Language: 1. Promts the user to enter 10 numbers. 2. saves those numbers in a 32 bit intege
    15·2 answers
  • It is the ornamentation of textiles and other material with needle work
    7·1 answer
  • I need help thanks please!
    8·2 answers
  • Modern Computers compared to earlier computers are
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!