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;
}