Easy Tutorial
❮ C Standard Library Float H C Examples Negative Positive Zero ❯

C Exercise Example 57

C Language Classic 100 Examples

Title: Drawing, using line to draw straight lines (implemented in TC).

Program Analysis: None.

Program Source Code:

//  Created by www.tutorialpro.org on 15/11/9.
//  Copyright © 2015 tutorialpro.org. All rights reserved.
//

#include "graphics.h"
int main()
{
    int driver, mode, i;
    float x0, y0, y1, x1;
    float j = 12, k;
    driver = VGA; mode = VGAHI;
    initgraph(&driver, &mode, "");
    setbkcolor(GREEN);
    x0 = 263; y0 = 263; y1 = 275; x1 = 275;
    for (i = 0; i <= 18; i++)
    {
        setcolor(5);
        line(x0, y0, x0, y1);
        x0 = x0 - 5;
        y0 = y0 - 5;
        x1 = x1 + 5;
        y1 = y1 + 5;
        j = j + 10;
    }
}

C Language Classic 100 Examples

❮ C Standard Library Float H C Examples Negative Positive Zero ❯