PENDULUM




#include <GRAPHICS.H>
#include <stdio.h>
#include<math.h>
#include<conio.h>
#include<dos.h>

void main()
{ clrscr();
int gd=DETECT,gm;
float xc=20,yc=40,x,y,l,r,a,i,rad;
initgraph(&gd,&gm,"f:\\TC\\bin\\BGI");
printf("\nEnter the length\n");
scanf("%f",&l);
printf("\nEnter radius\n");
scanf("%f",&r);
printf("\nEnter angle\n");
scanf("%f",&a);
a=a/2;
while(!kbhit)
{
for(i=-a;i<=a;i++)
{
rad=(3.14*i)/180;
x=xc+(l*sin(rad));
y=yc+(l*cos(rad));
line(xc,yc,x,y);
circle(x,y,r);
setfillstyle(SOLID_FILL,10);
floodfill(x,y,10);
delay(10);
cleardevice();

}
for(i=a;i>=-a;i--)
{
rad=(3.14*i)/180;
x=xc+(l*sin(rad));
y=yc+(l*cos(rad));
line(xc,yc,x,y);
circle(x,y,r);
setfillstyle(SOLID_FILL,10);
floodfill(x,y,10);
delay(10);
      cleardevice();
}
}
getch();
}

Comments