The rand() function (rand()%62) is used to generate a random number between 0 and 61, which is then used as the index to the character array chrs[] to create a new CAPTCHA each time. so creates a fresh captcha character, and this loop continues until n. (length of CAPTCHA)