0% found this document useful (0 votes)
5 views

Chatgpt 1

The document contains code for a C++ program that draws a red circle moving around the screen. The program initializes graphics mode, draws a circle, delays, updates the circle's position, and checks if it hits the screen edges to reverse direction.

Uploaded by

Asad Potekar
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Chatgpt 1

The document contains code for a C++ program that draws a red circle moving around the screen. The program initializes graphics mode, draws a circle, delays, updates the circle's position, and checks if it hits the screen edges to reverse direction.

Uploaded by

Asad Potekar
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

#include<graphics.

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

int main()
{
int gd = DETECT, gm;
int x = 10, y = 10, dx = 2, dy = 2;

initgraph(&gd, &gm, "C:\\TC\\BGI");

while(!kbhit())
{
clearviewport();
setcolor(RED);
circle(x, y, 10);
delay(20);
x = x + dx;
y = y + dy;

if(x > getmaxx() - 10 || x < 10)


dx = -dx;
if(y > getmaxy() - 10 || y < 10)
dy = -dy;
}

getch();
closegraph();
return 0;
}

You might also like