Computer Graphics Question

Hello
I am trying to make a homework. It has a lot of requirements. I have a question.
After I put two squares into their places in the rectangular, I need to change their color, but could not do it.
Here is my code.

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Save matrix state and do the rotation
 //glPushMatrix();
   // Define shapes enclosed within a pair of glBegin and glEnd
      // Each set of 4 vertices form a quad
glColor3f(0.0f, 1.0f, 0.0f); // Green
glRectf(x1, y1, x1+rsize, y1+rsize);// square 1
glColor3f(1.0f, 0.0f, 0.0f); // Red
glRectf(x2, y2, x2+r2size, y2+r2size);//square 1

glColor3f(1.0f,0.0f,1.0f) ;
glRectf(x3, y3,(x3+r3size),(y3+(r3size*2)));// rectangular
   if(x1==x3&&y1==y3){                 
    xstep=0;
    ystep=0;
          
     }
    
    if((x2==x1)&&(y2==y1+r2size)){
    x1step=0;
    y1step=0;
 
    }

I doubt there art many people on this forum familiar with OpenGL, which I’m assuming this is. I could be wrong, though.

https://en.wikibooks.org/wiki/OpenGL_Programming/Basics/Color