Here is C++ code for midpoint circle algorithm.
//MPC
#include<graphics.h>
#include<stdlib.h>
#include<stdio.h>
#include<conio.h>
#include<dos.h>
#include<iostream.h>
void main()
{
int gdriver=DETECT,gmode,errorcode;
initgraph(&gdriver,&gmode,"c:\\tc\\bgi");
int xm=getmaxx()/2;
int ym=getmaxy()/2;
cout<<"\n Enter radius:";
int r;
cin>>r;
int x=0;
int y=r;
float d=1.25-r;
while(x<=y)
{
putpixel(xm+x,ym-y,15);
putpixel(xm+y,ym-x,15);
putpixel(xm+y,ym+x,15);
putpixel(xm+x,ym+y,15);
putpixel(xm-x,ym+y,15);
putpixel(xm-y,ym+x,15);
putpixel(xm-y,ym-x,15);
putpixel(xm-x,ym-y,15);
if(d<0)
{
d+=(2*x)+3;
}
else
{
d=d+(2*(x-y))+5;
y=y-1;
}
x=x+1;
}
getch();
closegraph();
}
Output: