Q:

Write a C Program to perform Bouncing Ball using graphics

0

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

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

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 .

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

C Graphic Solved Programs – C Programming

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
Write a C Program to perform Moving Wheel using gr... >>
<< Write a C Program to perform Chess Board using gra...