Write a C Program to perform Bouncing Ball using graphics

By | 02.12.2016

Perform Bouncing Ball using graphics


Write a C Program to perform Bouncing Ball using graphics. Here’s simple Program to perform Bouncing Ball using graphics in C Programming Language.


Below is the source code for C Program to perform Bouncing Ball using graphics which is successfully compiled and run on Windows System to produce desired output as shown below :


SOURCE CODE : :


/*   C Program to perform Bouncing Ball using graphics  */

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<dos.h>
void main() {
        int gd = DETECT, gm = DETECT;
        int x, y = 0, j, t = 400, c = 1;
        initgraph(&gd, &gm, "");
        setcolor(RED);
        setfillstyle(SOLID_FILL, RED);
        for (x = 40; x < 602; x++) {
                cleardevice();
                circle(x, y, 30);
                floodfill(x, y, RED);
                delay(40);
                if (y >= 400) {
                        c = 0;
                        t -= 20;
                }
                if (y <= (400 - t))
                            c = 1;
                y = y + (c ? 15 : -15);
        }
        getch();
}

Above is the source code for C Program to perform Bouncing Ball using graphics which is successfully compiled and run on Windows System.The Output of the program is shown above .

If you found any error or any queries related to the above program or any questions or reviews , you wanna to ask from us ,you may Contact Us through our contact Page or you can also comment below in the comment section.We will try our best to reach up to you in short interval.


Thanks for reading the post….

5 1 vote
Article Rating
Category: C Programming Graphic Programs Tags:

About Tunde A

My name is Tunde Ajetomobi, a Tech Enthusiast and Growth Hacker. I enjoy creating helpful content that solves problem across different topics. Codezclub is my way of helping young aspiring programmers and students to hone their skills and find solutions on fundamental programming languages.

Subscribe
Notify of
guest
1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
C programmer

Here is another G graphics program for jumping ball animation