Featured Post

Step Wise Project Planning

Planning is the most difficult process in project management. The framework described is called the Stepwise method to help to distinguis...

  1. Home

Write a program to move a character along circumference

#include<graphics.h>
#include<dos.h>
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int x_cor,y_cor,radius,x,y;
float y1,y2,t,q;
int gd=DETECT,gm;
printf("Enter Centre Co-ordinates of a circle :- ");
scanf("%d %d",&x_cor,&y_cor);
printf("\n Enter the Radius of a Circle:- ");
scanf("%d",&radius);
initgraph(&gd,&gm," ");
for(x=x_cor-radius;x<=x_cor+radius;x++)
{
t=radius*radius-(x-x_cor)*(x-x_cor);
q=sqrt(t);
y1=y_cor-q;
putpixel(x,y1,WHITE);
y2=y_cor+q;
putpixel(x,y2,WHITE);
}

for(x=x_cor-radius;x<=x_cor+radius;x++)
{
t=radius*radius-(x-x_cor)*(x-x_cor);
q=sqrt(t);
y=y_cor-q;
setcolor(WHITE);02
outtextxy(x,y-20,"M");
delay(100);
setcolor(BLACK);
outtextxy(x,y-20,"M");
}

for(x=x_cor+radius;x>=x_cor-radius;x--)
{
t=radius*radius-(x-x_cor)*(x-x_cor);
q=sqrt(t);
y=y_cor+q;
setcolor(WHITE);
outtextxy(x,y+14,"M");
delay(100);
setcolor(BLACK);
outtextxy(x,y+14,"M");
}
getch();

}
Previous
Next Post »