By | 02.12.2016

# Draw a Circle using Mid-Point Algorithm

Write a C Program to Draw a Circle using Mid-Point Algorithm. Here’s simple Program to Draw a Circle using Mid-Point Algorithm in C Programming Language.

Below is the source code for C Program to Draw a Circle using Mid-Point Algorithm which is successfully compiled and run on Windows System to produce desired output as shown below :

## SOURCE CODE : :

```/*  C Program to Draw a Circle using Mid-Point Algorithm  */

#include<graphics.h>
#include<conio.h>
#include<stdio.h>
void plotpoints(int x, int y, int cx, int cy) {
putpixel(cx + x, cy + y, 4);
putpixel(cx - x, cy + y, 4);
putpixel(cx + x, cy - y, 4);
putpixel(cx - x, cy - y, 4);
putpixel(cx + y, cy + x, 4);
putpixel(cx - y, cy + x, 4);
putpixel(cx + y, cy - x, 4);
putpixel(cx - y, cy - x, 4);
}
void main() {
int cx, cy, x = 0, y, r, p;
int gd = DETECT, gm = DETECT;
clrscr();
printf("Enter the center \n");
scanf("%d%d", &cx, &cy);
scanf("%d", &r);
y = r;
p = 1 - r;
initgraph(&gd, &gm, "");
cleardevice();
while (x < y) {
plotpoints(x, y, cx, cy);
x++;
if (p < 0)
p += 2 * x + 1; else {
y--;
p += 2 * (x - y) + 1;
}
}
getch();
}```

Above is the source code for C Program to Draw a Circle using Mid-Point Algorithm which is successfully compiled and run on Windows System.The Output of the program is shown above .

If you found any error or any queries related to the above program or any questions or reviews , you wanna to ask from us ,you may Contact Us through our contact Page or you can also comment below in the comment section.We will try our best to reach up to you in short interval.

5 1 vote
Article Rating
Category: C Programming Graphic Programs Tags:

My name is Tunde Ajetomobi, a Tech Enthusiast and Growth Hacker. I enjoy creating helpful content that solves problem across different topics. Codezclub is my way of helping young aspiring programmers and students to hone their skills and find solutions on fundamental programming languages.

Subscribe
Notify of