This c graphics program performs countdown for 30 seconds.

C program countdown code

[pastacode lang=”c” manual=”%23include%20%3Cgraphics.h%3E%0A%23include%20%3Cdos.h%3E%0A%23include%20%3Cconio.h%3E%0A%20%0Aint%20main()%0A%7B%0A%20%20%20int%20gd%20%3D%20DETECT%2C%20gm%2C%20i%3B%0A%20%20%20char%20a%5B5%5D%3B%0A%20%0A%20%20%20initgraph(%20%26gd%2C%20%26gm%2C%20%22C%3A%5C%5CTC%5C%5CBGI%22)%3B%0A%20%0A%20%20%20settextjustify(%20CENTER_TEXT%2C%20CENTER_TEXT%20)%3B%0A%20%20%20settextstyle(DEFAULT_FONT%2CHORIZ_DIR%2C3)%3B%0A%20%20%20setcolor(RED)%3B%0A%20%0A%20%20%20for%20(i%20%3D%2030%3B%20i%20%3E%3D0%3B%20i–)%0A%20%20%20%7B%0A%20%20%20%20%20%20sprintf(a%2C%22%25d%22%2Ci)%3B%0A%20%20%20%20%20%20outtextxy(getmaxx()%2F2%2C%20getmaxy()%2F2%2C%20a)%3B%0A%20%20%20%20%20%20delay(1000)%3B%0A%20%0A%20%20%20%20%20%20if%20(%20i%20%3D%3D%200%20)%0A%20%20%20%20%20%20%20%20%20break%3B%0A%20%20%20%20%20%20cleardevice()%3B%0A%20%20%20%7D%0A%20%0A%20%20%20getch()%3B%0A%20%20%20closegraph()%3B%0A%20%20%20return%200%3B%0A%7D” message=”” highlight=”” provider=”manual”/] [ad type=”banner”]

 

Categorized in: