F How can we draw a system of circles of increasing size beginning from the top left corner of the screen using C ? | CodeTheta

How can we draw a system of circles of increasing size beginning from the top left corner of the screen using C ?

May 18, 2013

In this c programming is related to graphics programming when you will run this program in you own mechine do not forget to set the path. of you don't the program will not work

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#define GPATH "C:\\TC\\BGI"
void mp(int, int, int);
void cpp(int,int,int,int,int);
void main()
{
int xc, yc, r, i;
int gd=DETECT, gm;
i=0;
initgraph(&gd, &gm, GPATH);
while(!kbhit() && i<500)
{
mp(i,i,i);
circle(i,i,i);
i=i++;
delay(100);
}
getch();
}

void mp( int r, int xc, int yc)
{
int x, y, p,i;
x=0;
y=r;
p=1-r;
i=0;
cpp(xc, yc, x, y, i);
while(x<=y)
{
x++;
if(p<0)
p+=2*(x-1);
else
{
p+=2*(x-y)+1;
y--;
}
cpp(xc, yc, x, y, i);
i++;
}
}

void cpp(int xc, int yc, int x, int y, int i)
{
setcolor(i);
putpixel(xc+x, yc+y, i);
putpixel(xc+y, yc+x, i);
putpixel(xc-x, yc+y, i);
putpixel(xc+y, yc-x, i);
putpixel(xc+x, yc-y, i);
putpixel(xc-y, yc+x, i);
putpixel(xc-x, yc-y, i);
putpixel(xc-y, yc-x, i);
}
Try this code in your computer for better understanding. Enjoy the code. If you have any Question you can contact us or mail us

Post a Comment