Jun 6, 2007

C++ program to draw and move a circle on the screen

// C++ program to draw and move a circle on the screen (up and down). when hit any key from the keyboard circle will stop moving and program ends if you don't press any key from the keyboard circle will move on the screen infinite times. Here in this program kbhit() function is
used. it checks for the keyboard keystroke.

#include<iostream.h>
#include<conio.h>
#include<graphics.h>
#include<dos.h>

main()
{
clrscr();
int driver,mode;
driver = DETECT;
initgraph(&driver,&mode,"");

while (!kbhit())
{
for (int i=1;i<=400; i++)
{
circle(300,i,10);
delay(10);
cleardevice();
}

for ( i=400;i>=1; i--)
{
circle(300,i,10);
delay(10);
cleardevice();
}

}
}

Technorati Tags : , , , ,

No comments:

Post a Comment

Infolinks In Text Ads

Total Pageviews

Powered by Blogger.

Dont Forget To Follow Us

Blog Archive