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.
Try this code in your computer for better understanding. Enjoy the code. If you have any Question you can contact us or mail us#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); void main() { int xc, yc,r,i; int gd=DETECT, gm; r=10;i=10; initgraph(&gd, &gm, GPATH); xc=getmaxx()/2; yc=getmaxy()/2; for(i=10;i<=50;i++) { mp(r, xc, yc); r+=2; } getch(); } void mp(int r, int xc, int yc) { int x, y, p; x=0; y=r; p=1-r; cpp(xc, yc, x,y); while(x<=y) { x++; if(p<0) p+=2*(x-1); else { p+=2*(x-y)+1; y--; } cpp(xc, yc, x, y); } } void cpp(int xc, int yc, int x, int y) { putpixel(xc+x, yc+y, WHITE); putpixel(xc+y, yc+x, WHITE); putpixel(xc-x, yc+y, WHITE); putpixel(xc+y, yc-x, WHITE); putpixel(xc+x, yc-y, WHITE); putpixel(xc-y, yc+x, WHITE); putpixel(xc-x, yc-y, WHITE); putpixel(xc-y, yc-x, WHITE); }
Post a Comment