Another way to ignore following newline character (due to hitting ENTER) after scanning the integer in variable label loops is:
scanf ("%d%*c", &loops);
Where, as per the man pages:
* Suppresses assignment. The conversion that follows occurs as usual, but no pointer is used; the result of the conversion is simply discarded.
This is very unlikely, but good habit to check for error during scanf:
errno = 0
scanf ("%d%*c", &loops);
if (errno != 0) perror ("scanf");
// act accordingly to avoid un-necessary bug in the code
For example in your code, loops is a local un-initialized variable, containing garbage. If scanf fails to fill the desired value, following while loop may run arbitrarily.