Thursday, November 18, 2010

Rotation of Fan in C

#include<graphics.h>
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
#include<dos.h>
#include<time.h>
#include<process.h>
#include<math.h>
void user();
float s1=0.0,s2=120.0,s3=240.0;
int midx,midy;
void main()
{
int gdriver = DETECT, gmode, errorcode;
initgraph(&gdriver, &gmode, "C:/TC/BGI");
errorcode = graphresult();
if (errorcode != grOk)
{
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1);
}
midx=getmaxx()/2;
midy=getmaxy()/2;
loop:
cleardevice();
circle(midx,midy,5);
setcolor(10);
line(midx,midy,(midx+100*cos(s1*3.14/180)),(midy-95*sin(s1*3.14/180)));
line(midx,midy,(midx+100*cos(s2*3.14/180)),(midy-95*sin(s2*3.14/180)));
line(midx,midy,(midx+100*cos(s3*3.14/180)),(midy-95*sin(s3*3.14/180)));
if(!kbhit()) //check for keystroke
{
s1+=10;
s2+=10;
s3+=10;
delay(25);
goto loop;
}
else //when key press
{
getch();
exit(0);
}
getch();
closegraph();
}

0 comments:

Post a Comment

Contact Form

Name

Email *

Message *