C Program to Draw a Rectangle using Graphics
x
20
20
1
2
3
4
main()
5
{
6
int gd, gm, x1, y1, x2, y2;
7
gd=DETECT;
8
initgraph(&gd, &gm, "C:\\TC\\BGI");
9
clrscr();
10
printf("Enter the left top coordinates (x1, y1):");
11
scanf("%d%d", &x1, &y1);
12
printf("Enter the right bottom coordinates (x2, y2):");
13
scanf("%d%d", &x2, &y2);
14
setcolor(BLUE);
15
rectangle(x1, y1, x2, y2);
16
floodfill(x1+5, y1+5, BLUE);
17
outtextxy(20, 450, "Press any key to continue...");
18
getch();
19
closegraph();
20
}
Output: