Bezier Curves and Bezier Surfaces generation with C/C++ in Code::Blocks

Brief Theory of Bezier Curve
In order to draw curvy surface we implement Bezier curve algorithm. In drawing Bezier we first define n+1 control point pk= (xk, yk, zk) with k varying from 0 to n. And the coordinate points are blended to produce following position vectors that define the path of an approximation Bezier polynomial function between p0 and pn.

The Bezier blending functions BEZk,n(u) are the Bernstein polynomials:  BEZk,n(u)=C(n,k)uk(1-u)n-k
Where the C(n, k) are binomial coefficients.
Equivalently, we can define Bezier blending functions with the recursion calculation.
BEZk,n (u) = (1-u) BEZk,n-1(u)+u BEZk-1,n-1(u), n>k≥1
With BEZk,k = uk , and BEZ0,k = (1-u)k.


C Source Code

#include 
#include 
#define ROUND(a) ((int) (a + 0.5)) 
/* set window handle */ 
static HWND sHwnd;
int a; 
void SetWindowHandle(HWND hwnd){
    sHwnd=hwnd;
} 
void setPixel(int x,int y,COLORREF color){
    if(sHwnd==NULL){
        MessageBox(NULL,"sHwnd was not initialized !","Error",MB_OK|MB_ICONERROR);
        exit(0);
    }
    HDC hdc=GetDC(sHwnd);
    SetPixel(hdc,x,y,color);
    ReleaseDC(sHwnd,hdc);
    return; 
// NEVERREACH // 
} 
float Coeff (int k, int n)
{
    int j;
    float coeff= 1.0;
    for (j=n; j>k; j--)            coeff *= j;
    for (j=n-k; j>k; j--)          coeff /= j;
    return(coeff);
} 
float BValue (int k, int n, float u, float coeff)
{
    int j;
    float bvl = coeff;
    for (j=1; j= -1) &&
    ((ypt[i]=(va_arg (Cord,int))) >= -1)
    && ( i

Note: to run this code in your machine with Code::blocks IDE, add a link
library libgdi32.a (it is usually inside MinGW\lib )  in linker setting.   
Output