Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Use a one-dimensional array to solve the following problem. Read in up to 20 num

ID: 3760603 • Letter: U

Question

Use a one-dimensional array to solve the following problem. Read in up to 20 numbers from the keyboard, each of the numbers should be between 10 and 100, inclusive. As each number is read, add the number to the array if it is not a duplicate of a number already read. If it is a duplicate, print out the word “duplicate.” You may terminate the input of numbers to the array if a zero is input. Use a function to return the value of true or false if an input number is already in the array.

Please, dont copy something from the internet and paste it here. I am reposting this question again because the previous answer was not the way I expected. I need real answer and This is a c++ question and please I need it in c++ form

Explanation / Answer

#include <iostream>
using namespace std;
bool check(int a[],int n,int input){
bool flag=true;
for(int i=0;i<n;i++){
if(input==a[i]){
flag=false;
}
}
return flag;
}
int main(){
int a[20];
int input,n=0;
while(input!=0){
cout<<"Enter the number between 10 and 100: ";
cin>>input;
if(input>=10&&input<=100){
if(check(a,n,input)){
a[n]=input;
n++;
}else{
cout<<"duplicate!!!"<<endl;
}
}
}
}