Coders Packet

Digital Clock using C++

By Priyanka Biswas

The project implements a digital clock on the console using C++, showcasing the current time.

This project uses the following header files: iostream, dos.h, conio.h, windows.h, time.h, along with ten character arrays for storing digits pattern from 0-9 and a separator (:) using the # symbol.

It has the following functions:-

void gotoxy(int x, int y): setting the cursor position anywhere within the console.

void setcursor (bool visible, DWORD size): making the cursor invisible on the cursor.

void printDigit(int no, int x, int y): printing digits as per the time from ten-character arrays made.

Inside the main() function: current time is fetched from the local machine using time_t now = time(0), converting that to string and accessing hour, minute, and the second component through it. Later we also check if the escape key is pressed to terminate the program using khbit() function and calling the printDigit() function to print the time on the console screen.

Output screen:

digital clock

Download Complete Code


No comments yet