putpixel function plots a pixel at location (x, y) of specified color.

Declaration :- void putpixel(int x, int y, int color);

For example if we want to draw a GREEN color pixel at (35, 45) then we will write putpixel(35, 35, GREEN); in our c program, putpixel function can be used to draw circles, lines and ellipses using various algorithms.

[ad type=”banner”]

C programming code for putpixel

#include<graphics.h>
#include<conio.h>

main()
{
int gd = DETECT, gm;

initgraph(&gd, &gm, "C:\\TC\\BGI");

putpixel(25, 25, RED);

getch();
closegraph();
return 0;
}

Output of this program will be a RED pixel on screen at (25, 25) . Try to spot that pixel with your eyes at left top portion of your computer screen.
[ad type=”banner”]

Categorized in: