0% found this document useful (0 votes)
4 views1 page

3 CG

The document contains a C program that uses graphics to draw a circle based on user-defined center coordinates and radius. It initializes a graphics window, takes input for the circle's center and radius, and uses the midpoint circle algorithm to plot the circle. The program concludes by closing the graphics window after displaying the circle.

Uploaded by

akbhai000008
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views1 page

3 CG

The document contains a C program that uses graphics to draw a circle based on user-defined center coordinates and radius. It initializes a graphics window, takes input for the circle's center and radius, and uses the midpoint circle algorithm to plot the circle. The program concludes by closing the graphics window after displaying the circle.

Uploaded by

akbhai000008
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Input Program:

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

void main()
{
int xc,yc,r,p,x,y;
int gd=DETECT,gm;
initgraph(&gd,&gm,"C:\\TURBOC3\\BGI");
clrscr();
printf("\n\n\tEnter the co-ordinates of center : ");
scanf("%d %d",&xc,&yc);
printf("\n\n\tEnter the radius: ");
scanf("%d",&r);

x = 0;
y = r;
p=(1-r);

for(x=0;x<=y;x++)
{
if(p < 0)
{
x=x+1;
y=y;
p = p+2*(x+1)+1;
}
else
{
x=x+1;
y=y-1;
p = p +2*(x+1)-2*(y);
}

putpixel(xc+x,yc-y,WHITE);
putpixel(xc-x,yc-y,WHITE);
putpixel(xc+x,yc+y,WHITE);
putpixel(xc-x,yc+y,WHITE);
putpixel(xc+y,yc-x,WHITE);
putpixel(xc-y,yc-x,WHITE);
putpixel(xc+y,yc+x,WHITE);
putpixel(xc-y,yc+x,WHITE);
}

getch();
closegraph();
}

Output:

You might also like