How to Create Design by C Graphics Program with Source Code

Different design by C programing language

Introduction :

Creating a design by graphics using C programing language is very popular in software world. By graphics library like the graphics.h in TurboC++ ide, you can create a variety of designs using C graphics program.

About The Program :

In this program, you see different type of design is create by C graphics program. Here different type design in build one by one with different color.

How run the program :

You can run this program in your pc. For run this program first install turboc++ in your pc. Now create a C or C++ file in turboc++. After that copy the below source code in your C or C++ file. If you do not know how to copy paste in turboc++ follow my link.
For Initialize the graphics mode you have to show the path of bgi folder of your pc like my code initgraph(&graphic_driver, &graphic_mode, “//turboc3/bgi”). Your path may be different as my bgi path.

Here I use the following function

Source Code :

The below source code is create different design in graphics programing mode. just copy the code and use in your project.

/* Develop by Puskar Jasu*/
#include <graphics.h>
#include <stdlib.h>
#include <conio.h>
#include <dos.h>
#include <math.h>
int main(void)
{
    int xmax, ymax, x, y, i = 0, j = 0, m = 0, n = 0, k = 0, a = x, b = y, radius = 5;
    int graphic_driver = DETECT, graphic_mode;
    initgraph(&graphic_driver, &graphic_mode, "//turboc3/bgi");
    x = getmaxx() / 2;
    y = getmaxy() / 2;
    setbkcolor(1);
    while (1)
    {
        setbkcolor(k + 1);
        setcolor(k);
        for (n = 0; n <= 350; n++)
        {
            for (m = 0; m <= 360; m += 10)
            {
                i = n * cos(m * 3.14159 / 180);
                j = n * sin(m * 3.14159 / 180);
                line(x, y, x + i, y - j);
            }
            delay(5);
            n++;
        }
        cleardevice();
        k++;
        if (k == 16)
        {
            k = 0;
            break;
        }
    }
    while (1)
    {
        setbkcolor(k + 1);
        setcolor(k);
        for (n = 0; n <= 100; n++)
        {
            for (m = 0; m <= 360; m += 10)
            {
                i = n * cos(m * 3.14159 / 180);
                j = n * sin(m * 3.14159 / 180);
                line(a, b, a + i, b - j);
            }
            delay(5);
            n++;
        }
        cleardevice();
        a = rand() % xmax;
        b = rand() % ymax;
        k++;
        if (k == 16)
        {
            k = 0;
            break;
        }
    }
    while (1)
    {
        setbkcolor(15);
        setcolor(k);
        for (i = 1; i <= 40; i++)
        {
            circle(x, y, radius);
            delay(50);
            radius = radius + 5;
        }
        setcolor(15);
        for (i = 1; i <= 41; i++)
        {
            circle(x, y, radius);
            delay(50);
            radius = radius - 5;
        }
        k++;
        if (k == 15)
        {
            k = 0;
            break;
        }
    }
    cleardevice();
    setbkcolor(4);
    m = 0;
    while (1)
    {
        setcolor(14);
        circle(x + 100, y, 100);
        circle(x - 100, y, 100);
        if (m <= 360)
        {
            setcolor(k);
            i = 100 * cos((180 + m) * 3.14159 / 180);
            j = 100 * sin((180 + m) * 3.14159 / 180);
            circle(x + 100 + i, y - j, 20);
            delay(5);
            m++;
        }
        if (m > 360)
        {
            setcolor(k);
            i = 100 * sin((0 + m - 270) * 3.14159 / 180);
            j = 100 * cos((0 + m - 270) * 3.14159 / 180);
            circle(x - 100 + i, y - j, 20);
            delay(5);
            m++;
            if (m == 720)
            {
                m = 0;
                break;
            }
        }
        k++;
    }
    getch();
    closegraph();
    return 0;
}

Conclusion :

In this program I show you how you build a program which show different design using C or C++ language. You can see the output in my youtube channel.

If you use my code in your project, I shall be glad to you thanks.

You can also see my other program :

You can see my other blog :

Scroll to Top