what code can i use to make a loop that will find random numbers in the rang of 1 - 13 till all numbers in that range are used 4 times this is what i would use to just make a loop that finds random numbers for (int x; x <= 52; x++) // loop till x = 52 { srand((unsigned)time(NULL)); // seed rand y += 1 + rand() % (13); //find a random number in the rang of 1 - 13 cout << y << endl; // display random number }

Here's one way: Code: void test30() { int test[13]; srand((unsigned)time(NULL)); for (int i=0; i<13; test[i++]=0) ; int count=0, p=0; while (count<52) { int r=rand()%13; if (test[r]<4) { test[r]++; count++; printf("%2d ",r+1); p++; if (p>12) { printf("\n"); p=0; } } } }