How generate the revolution surface rotating a circle around x-axis

PLEASE IT IS IMPORTANT!
I have to create a revolution surface from a closed curve (rotating it around x-axis). I have chosen a circle. I have tried to apply the following code, but it works only for open curves, but not for closed ones; it’s the following:

float polyint ( float  points[][3], float x, int N )
    {
      float y;
    
      float num = 1.0, den = 1.0;
      float sum = 0.0;
    
      for ( int i = 0; i < N; ++i ) {
        num = den = 1.0;
        for ( int j = 0; j < N; ++j ) {
          if ( j == i ) continue;
    
          num = num * ( x - points[j][0] );         //x - xj
        }
        for ( int j = 0; j < N; ++j ) {
          if ( j == i ) continue;
          den = den * ( points[i][0] - points[j][0] );  //xi - xj
        }
        sum += num / den * points[i][1];
      }
      y = sum;
    
      return y;
    }
    
    float aLine ( float x )
    {
      return x + 2.5;
    }
    
    void display(void)
    {
       int i, j;
       float x, y, z, r;                //current coordinates
       float x1, y1, z1, r1;            //next coordinates
       float theta;
    
       glClear(GL_COLOR_BUFFER_BIT);
       glColor3f(0.0, 1.0, 1.0);
       const float startx = cos(0), endx = cos(2*PI);
       const int nx = 20;               //number of slices along x-direction
       const int ntheta = 20;           //number of angular slices
       const float dx = (endx - startx) / nx;   //x step size
       const float dtheta = 2*PI / ntheta;      //angular step size
    
       x = startx;
       //r = aLine ( x );
       r = polyint( ctrlpoints, x, 4);
       glPushMatrix();
       glRotatef( anglex, 1.0, 0.0, 0.0);           //rotate the object about x-axis
       glRotatef( angley, 0.0, 1.0, 0.0);           //rotate about y-axis   
       glRotatef( anglez, 0.0, 0.0, 1.0);       //rotate about z-axis
      
       for ( i = 0; i < nx; ++i ) {         //step through x
          theta = 0;
          x1 = x + dx;              //next x
          //r1 = aLine ( x1 );          //next f(x)
          r1 = polyint( ctrlpoints, x1, 4);     //next f(x)
          //draw the surface composed of quadrilaterals by sweeping theta
          glBegin( GL_QUAD_STRIP );
        for ( j = 0; j <= ntheta; ++j ) {
          theta += dtheta;
          double cosa = cos( theta );
          double sina = sin ( theta );
          y = r * cosa;  y1 = r1 * cosa;    //current and next y
          z = r * sina;  z1 = r1 * sina;    //current and next z
         
          //edge from point at x to point at next x
          glVertex3f (x, y, z);
          glVertex3f (x1, y1, z1);
          
          //forms quad with next pair of points with incremented theta value    
        }               
          glEnd();
          x = x1;
          r = r1;   
       } //for i
    }

In case of closed curve I have used for circle:
crtlpoints[4][3]={cos(0.), sin(0.), 0.},{cos(2/3*PI), sin(2/3*PI), 0},{cos(5/3*PI), sin(5/3*PI), 0}, {cos(2*PI), sin(2*PI), 0} .
polyint() is instead a function for interpolation of N points. I have thought that the problem is on the fact that endx=startx for a closed curve…Please can you tell me how do I make it work also for closed curve?

Your rotational buildup looks sane. If it works for some open poly-line you obviously should look at the f(x) that you seem to assume is a closed curve. I’ll not attempt to understand it, and it’s not openGL. If your closed curve has start-positions both above and below the x-axis … it would seem that you’ll hide part of the surface in the inside. The operation should produce a tourus.
You have not bothered to tell us about the visual output of the code … how does it fail to meet your expectations?

For circle I have used the following code and the torus appears. But sorry now my problem is exactly this:

         int i, j; 
             float x, y, z, r; 
              float x1, y1, z1, r1; 
              float alpha;
        const int nx = 200; 
        const int nalpha = 100; 
        const float dx = (endx - startx) / nx; 
        const float dalpha = 2 * PI / nalpha; 
            float x0 = startx; 
	x=fun2(x0);
        r=fun(x0);
      
       
         for (i = 0; i < nx; ++i) { //step through x
                
                alpha = 0;	
                float x3 = x+dx; 
                x1=fun2(x3);

                r1 = fun(x3); 
                
               
                glBegin(GL_QUAD_STRIP); 
                for (j = 0; j <= nalpha; ++j) {
                        alpha += dalpha; 
                        double cosa = cos(alpha); 
                        double sina = sin(alpha); 
                        
                        y = r * cosa;
                        y1 = r1 * cosa; 
                       
                        z = r * sina;
                        z1 = r1 * sina; 

           
                        glNormal3f(x, y, z);
                        glVertex3f(x, y, z);
                        
                        glNormal3f(x1, y1, z1); 
                        glVertex3f(x1, y1, z1); 

                      
                }
                glEnd(); 	                
                
                x = x1;
                r=r1;
               
        }

       
        
        glFlush();  
    }

}

Where my curve if it is given like (fun2=t^2, fun=t+1) for startx=0 and endx=5 my surface is not visible. Why?? PLEASE HELP ME I DONT’ KNOW WHAT I SHOULD DO.

have you tried to scrutinize the output from your functions with
cout<<
?
… I’m loosing my hearing if you keep shouting.

If you’r not using the viewport and an appropriate orthographic projection, you should look into it. If none are present coordinates outside the range -1 -> 1 may not be shown.