# Duplicate Input

I m trying to run a program to show arraySize[20] of numbers 10 to 100 inclusive. Numbers not within range r 'Invalid' - hv got it. But I can't get seem to get the formula in order to output 'Duplicate numbers' (as each number is read, print it only if it is not a duplicate of a number already read). Meaning the output of the 20 numbers will be different. Below r the what I have done.
Somebody out there, help me?

#include

int linearSearch (const int [], int, int);

int main()

{
const int arraySize = 20;
int num[arraySize], searchKey, ;

for (int i=0; i<=arraySize; i++) {
num[i] = 10 + i;

cout << "Enter a number between 10 & 100 inclusive : ";
cin >> searchKey;

if (searchKey >= 10 && searchKey <= 100);
else
cout << "Invalid number!!! Choose another
number : " << endl;

//(wrong...) if (searchKey == num[arraySize)
// cout << "Duplicate number!!!" << endl;
}

return 0;

}

• : I m trying to run a program to show arraySize[20] of numbers 10 to 100 inclusive. Numbers not within range r 'Invalid' - hv got it. But I can't get seem to get the formula in order to output 'Duplicate numbers' (as each number is read, print it only if it is not a duplicate of a number already read). Meaning the output of the 20 numbers will be different. Below r the what I have done.
: Somebody out there, help me?
:
: #include
:
: int linearSearch (const int [], int, int);
:
: int main()
:
: {
: const int arraySize = 20;
: int num[arraySize], searchKey, ;
:
: for (int i=0; i<=arraySize; i++) {
: num[i] = 10 + i;
:
: cout << "Enter a number between 10 & 100 inclusive : ";
: cin >> searchKey;
:
: if (searchKey >= 10 && searchKey <= 100);
: else
: cout << "Invalid number!!! Choose another
: number : " << endl;
:
: //(wrong...) if (searchKey == num[arraySize)
: // cout << "Duplicate number!!!" << endl;
: }
:
: return 0;
:
: }
:
:
:
Your program is incorrect as some of your variables are not declared at the beginning of your program.

Now, to enter in the numbers within a specified range, try this:

[code]
#include <iostream>
using namespace std;

int main()
{
// Declaring the variables
int arraySize = 20;
int num[arraySize];
int i, j;
int searchKey[arraySize];

// Beginning of 'for' loop
for(i=0; i < 11; i++)
{
// User enters 10 numbers within the specified range
cout << "Enter 10 number between 10 & 100 inclusive: ";
cin >> searchKey[i];

if(searchKey[i] >= 10 && searchKey[i] <= 100)
{
// Print out the number
cout << searchKey[i] << "
";
}
else
{
cout << "Invalid number!!!
";
cout << "
Choose another number:
";
}
// End of 'for' loop
}

return 0;
}
[/code]

and in order to check for duplicate numbers, you may need to use an [b]if - else[/b] statement.