You can usually repeat a part of a program by

while(condition)
{
code
}

or

for (int x = whatever; x < something; x++)