This blog is under construction

Wednesday, 4 September 2013

C program to implement digital clock using graphics

Implement Digital Clock Using C Graphics

  #include <stdio.h>
  #include <conio.h>
  #include <graphics.h>
  #include <time.h>
  #include <dos.h>
  #include <string.h>

  int main() {
        /* request auto detection */
        int gdriver = DETECT, gmode;
        int midx, midy, err;
        long mytime;
        char date[256];

        /* initialize graphic mode */
        initgraph(&gdriver, &gmode, "C:/TURBOC3/BGI");
        err = graphresult();

        if (err != 0) {
                /* error occurred */
                printf("Graphics Error: %s\n",
                return 0;

        /* mid positions in x and y axis */
        midx = getmaxx() / 2;
        midy = getmaxy() / 2;

        /* mid positions in x and y axis */
        midx = getmaxx() / 2;
        midy = getmaxy() / 2;

        while (!kbhit()) {
                /* clears graphic screen */

                /* get time in seconds */
                mytime = time(NULL);

                /* store the date and time in the given string */
                strcpy(date, ctime(&mytime));

                settextjustify(CENTER_TEXT, CENTER_TEXT);
                settextstyle(TRIPLEX_FONT, HORIZ_DIR, 3);

                /* locate the postion to write */
                moveto(midx, midy);

                /* print the date and time */

                /* sleep for a second */


        /* deallocate memory allocated for graphic screen */
        return 0;

Output: (c program to implement digital clock)


  1. can you please help me...? I want to become a great programmer, even though Im too young.. give me a tutorial for all of your knowledge about programming.. thanks.. :)

  2. It has been simply incredibly generous with you to provide openly what exactly many individuals would’ve marketed for an eBook to end up making some cash for their end, primarily given that you could have tried it in the event you wanted.

    Data Science Interview Questions

    Angular JS Interview Questions

    Big Data Training in Velachery

    AWS Certified Developer

    Best Resource of Learning Devops

    Blueprism Interview Questions

    Automation Anywhere Interview Questions