draw random colored squares

so im trying draw random colored squares like the image attached. i can draw a random square but am having trouble getting it to look like the one in image. my code so far :

glPushMatrix();
glTranslatef(xpos, ypos, 0);
glColor3ub( rand()%255, rand()%255, rand()%255 );
glBegin(GL_QUADS);
glVertex2i(0,0);
glVertex2i(1,0);
glVertex2i(1,1);
glVertex2i(0,1);
glEnd();
glPopMatrix();