C Program to Draw a Rectangle using Graphics
#include<stdio.h> #include<conio.h> #include<graphics.h> main() { int gd, gm, x1, y1, x2, y2; gd=DETECT; initgraph(&gd, &gm, "C:\\TC\\BGI"); clrscr(); printf("Enter the left top coordinates (x1, y1):"); scanf("%d%d", &x1, &y1); printf("Enter the right bottom coordinates (x2, y2):"); scanf("%d%d", &x2, &y2); setcolor(BLUE); rectangle(x1, y1, x2, y2); floodfill(x1+5, y1+5, BLUE); outtextxy(20, 450, "Press any key to continue..."); getch(); closegraph(); }
Output: