For numbers with a small range, make an int array (auxiliary). Say the range was 0 to 1000:
Code:
#include <stdio.h>
#define SIZE 1000
int main() {
int i, unique, temp;
int num[SIZE];
printf("\n\n");
for(i=0;i<SIZE;i++)
num[i] = 0;
i=1;
while(i) {
printf("\n Enter a positive integer. First repetition quits: ");
temp = scanf("%d", &unique);
getchar();
if(temp && unique > -1 && unique < SIZE) {
num[unique]++;
if(num[unique]>1) {
printf("\n Repetition detected - terminating loop");
i=0;
}
}
}
i=getchar();
printf("\n\n\t\t\t press enter when ready");
i = getchar();
return 0;
}
For numbers with a large range, you'll have to either check every number in the array.
Note that the above is approximately the same as getting unique numbers by only allowing numbers from a fixed set or "draw" (which are unique), to be chosen.