Write a program to create windmill with speed control speed up have press ‘h’ speed decrease have press ‘d’ you want to exit press ‘E’.
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<dos.h>
void main()
{
int ch;
int gdriver=DETECT,gmode;
int xc,yc,i,speed=250;
int stangle=0,endangle=30,radius=100;
initgraph(&gdriver,&gmode,"c:\\tc\\bgi");
xc=getmaxx()/2;
yc=getmaxy()/2;
while(1) {
stangle=0;
endangle=30;
for(i=0;i<12;i++)
cleardevice();
setfillstyle(i,i);
circle(xc,yc,10);
outtextxy(250,100,"pawanchakki");
outtextxy(10,5,"Er.UmeshSohaliya");
outtextxy(10,15,"ph-9978748582");
outtextxy(10,30,"press h to increase sped");
outtextxy(10,40,"press d to dcrease sped");
outtextxy(10,50,"press e to exit");
setbkcolor(RED);
rectangle(xc-5,yc,xc+5,yc+200);
rectangle(xc-20,yc+200,xc+20,yc+225);
pieslice(xc,yc,stangle,endangle,radius);
pieslice(xc,yc,stangle+120,endangle+120,radius);
pieslice(xc,yc,stangle+240,endangle+240,radius);
stangle=endangle;
endangle +=30;
setcolor(GREEN);
delay(speed);
if(kbhit())
{
ch=getch();
if(ch=='h')
if(speed>10)
speed -=20;
if (ch== 'd')
if(speed<1000)
speed +=10;
if(ch=='e')
exit(0);
}
setcolor(YELLOW);
}
closegraph();
getch();
}
No comments:
Post a Comment