1. To show rectangle for computer graphics #include #include int main() { int gd = DETECT, gm; initgraph(&gd, &gm, ""); // Initialize graphics // Coordinates of top-left and bottom-right corners of the rectangle int left = 100, top = 100, right = 300, bottom = 200; // Draw rectangle rectangle(left, top, right, bottom); // Close graphics closegraph(); return 0;} 2. To show triangle for computer graphics #include #include int main() { int gd = DETECT, gm; initgraph(&gd, &gm, NULL); int x1 = 100, y1 = 100; int x2 = 300, y2 = 100; int x3 = 200, y3 = 300; line(x1, y1, x2, y2); line(x2, y2, x3, y3); line(x3, y3, x1, y1); delay(5000); // Pause for 5 seconds closegraph(); return 0;} 3. To show circle for computer graphics #include #include #include void drawCircle(int xc, int yc, int x, int y) { putpixel(xc + x, yc + y, WHITE); putpixel(xc - x, yc + y, WHITE); putpixel(xc + x, yc - y, WHITE); putpixel(xc - x, yc - y, WHITE); putpixel(xc + y, yc + x, WHITE); putpixel(xc - y, yc + x, WHITE); putpixel(xc + y, yc - x, WHITE); putpixel(xc - y, yc - x, WHITE);} void bresenhamCircle(int xc, int yc, int r) { int x = 0, y = r; int d = 3 - 2 * r; while (x <= y) { drawCircle(xc, yc, x, y); x++; if (d > 0) { y--; d = d + 4 * (x - y) + 10; } else { d = d + 4 * x + 6; } drawCircle(xc, yc, x, y); }} int main() { int gd = DETECT, gm; initgraph(&gd, &gm, ""); int xc = 250, yc = 250, radius = 100; bresenhamCircle(xc, yc, radius); getch(); closegraph(); return 0;} 4. To show square for computer graphics:- #include int main() { int gd = DETECT, gm; initgraph(&gd, &gm, ""); // Coordinates of the square's vertices int x1 = 100, y1 = 100; int x2 = 200, y2 = 100; int x3 = 200, y3 = 200; int x4 = 100, y4 = 200; // Draw the square using lines line(x1, y1, x2, y2); line(x2, y2, x3, y3); line(x3, y3, x4, y4); line(x4, y4, x1, y1); delay(5000); // Display for 5 seconds closegraph(); return 0;} 5. To show Rhombus for computer graphics:- #include int main() { int n, i, j, space; printf("Enter the number of rows: "); scanf("%d", &n); space = n - 1; for (i = 1; i <= n; i++) { for (j = 1; j <= space; j++) { printf(" "); } space--; for (j = 1; j <= 2 * i - 1; j++) { printf("*"); } printf("\n"); } space = 1; for (i = 1; i <= n - 1; i++) { for (j = 1; j <= space; j++) { printf(" "); } space++; for (j = 1; j <= 2 * (n - i) - 1; j++) { printf("*"); } printf("\n"); } return 0;} Please note that the "graphics.h" library is specific to the Turbo C compiler and DOS-based systems. It might not work on modern systems without compatibility adjustments. If you're working on a different environment, you might want to explore graphics libraries like SDL, OpenGL, or other alternatives.