C++ program to draw Pixels using for loop
kw.cpp
#include <graphics.h>
int main()
{
    int i;
    int n = 50, x = 50, y = 50;
    int gm = VGAMAX, gd = DETECT;
    initgraph(&gd, &gm, NULL);
    for (i = 0; i < n; i++)
    {
        x = x + 5;
        putpixel(x, y, WHITE);
    }
    delay(7000);
    return 0;
}
Output
kodingwindow@kw:~$ g++ kw.cpp -lgraph
kodingwindow@kw:~$ ./a.out
Advertisement