I am learning C and currently trying to understand why in the code part below the while loop is executed before the for loop!?
The code should display a 3-digit random number and then wait n seconds.
srand(time(NULL));
time_t rnd_number_length = 3;
for (int i=0; i < rnd_number_length; i++) {
printf("%d ", rand() % 10);
}
clock_t waiting_time = clock() + 5 * CLOCKS_PER_SEC;
while(clock() < waiting_time) {}
However, when I compile and run this code, the program waits first and only then displays the random digits. Why is this happening?