To draw a rectangle in Turbo Pascal, you can use the Rectangle procedure from the Graph unit. First, initialize the graphics mode with InitGraph, then specify the coordinates for the top-left and bottom-right corners of the rectangle. Use the Rectangle function with these coordinates, and finally, use CloseGraph to exit the graphics mode. Here’s a simple example:
<code class="language-pascal">uses Graph;var gd, gm: Integer;
begin gd := Detect; InitGraph(gd, gm, ''); Rectangle(100, 100, 300, 200); // Draws a rectangle ReadLn; // Wait for user input CloseGraph; end.
</code>
Copyright © 2026 eLLeNow.com All Rights Reserved.