Hey, I am having an issue with this program. Here is the question Use a one-dime
ID: 3612327 • Letter: H
Question
Hey,I am having an issue with this program.
Here is the question
Use a one-dimensional array to solve the following program: Read in20 numbers, each of which is between 10 and 100, inclusive. As eachnumber is read in, validate it and store it in the array only if itis not a duplicate of a number already read. After reading all thevalues, display only the unique values that the user hasentered.
Here is my attempt
#include <iostream>
using namespace std;
int main(){
int i, x=0,n, a[9];
cout<<"Enter number between 10 and 100: ";
for(int count=1;count<=20;count++){
cin>>n;
if(n<10||n>100){
cout<<"Invalid number ";
}
for(i=0;i<x;i++){
if(a[i]==n)
break;
}
if(i==x){
a[x]=n;
x++;
}
else
cout<<"Duplicate number. ";
}
cout<<" The nonduplicate valuesare: ";
for(i=0;i<x;i++)
cout<<" "<<a[i];
cout<<" ";
system("pause");
return 0;
}
Please help me out!! Thanks, I wil def rate you.
Explanation / Answer
Hi there,
You're allmost there! Keep up the good work!
Cheers, niels