duplicate numbers

This is a discussion on duplicate numbers within the C Programming forums, part of the General Programming Boards category; good day to you guys... my first time here... i just would like to ask if given the series of ...

1. duplicate numbers

good day to you guys... my first time here...
i just would like to ask if
given the series of numbers 8 1 5 9 4 5
how can i create a program in C to print to screen that there is a duplicate number which is 5...
thanks

2. How do you yourself find if there are duplicate numbers? Well, that's pretty easy. You start with the first number, and look in the whole list for it. Then you pick the next, and so on. Give it a shot.

Quzah.

3. If the list tends to be large
you should sort the list
and then loop through, checking if successive numbers are equal.

4. Actually what is better than a sort is something like so...

Code:
```/* Pseudocode... */

Create an array the size of the frequency of numbers
For each number in the list
add one to the spot on the frequency array
Print the index of each spot with the number 2```
Code:
```// list contains numbers from 1 to 100
// the frequency array will need to have each number the list has so we must make
// the last position 100 so we can use 1 instead of 0
int frequency[100+1] = { 0 };

int size = sizeof (list);
for (int loop = 0; loop < size; loop++) {
frequency[ list[loop] ]++;
}

for (int index = 1; index <= 100; index++) {
if (frequency[index] == 2)
printf("Duplicate number in list: %d", index);
}```

5. i did it... thank you very much...

6. this looks more correct:

Code:
```for (i =0; i < sizeof(list) / sizeof(list[0]); i++)
if (list[i]++)
printf("duplicate: %d", i);```

7. Of course, if the range is small, this method is OK. But if the range is big, for example,
there could be 32-bit numbers, it will not work: the 'list' array gonna take too much memory.
In this case, other methods should be used, so numbers must be organized in another