BACK TO 10+2 STEM LAB
10+2 MATHEMATICS & DRAWINGS•2020-01-01•2 MIN READ

Making Analogue Clock with C-Language using Graphics

Hi Friends here is another small project Analogue Clock made with C-Language. Here I have used Graphics of turbo C, and for the hand of houres and minute and second use pie slice.

Key Architecture Takeaways

  • ›
    Point 1: Core computer science and engineering computing concept: Making Analogue Clock with C-Language using Graphics.
  • ›
    Point 2: Detailed trace of memory representation, algorithmic complexity, and control structures.
  • ›
    Point 3: Includes portable ISO C (C17/C23) code examples verified with modern GCC and Clang.
Notice

Compiler & Toolchain Modernization

While legacy educational environments used 16-bit DOSBox Turbo C++, all code presented here adheres to standard ANSI/ISO C standards. You can compile these programs cleanly on modern Linux, Windows (MSYS2/WSL), or macOS using:

bash
> gcc -Wall -Wextra -O2 program.c -o program
> ./program
> ```


---

Hi Friends here is another small project Analogue Clock made with C-Language. Here I have used Graphics of turbo C, and for the hand of houres and minute and second use pie slice.

## Screenshot:

[![](https://www.technhit.in/wp-content/uploads/2020/01/clock.png)](https://www.technhit.in/wp-content/uploads/2020/01/clock.png)

## [![](https://www.technhit.in/wp-content/uploads/2020/01/clock.gif)](https://www.technhit.in/wp-content/uploads/2020/01/clock.gif)

## Code for Analogue Clock.

c #include<stdio.h> #include<conio.h> #include<stdlib.h> #include<string.h> #include<alloc.h> #include<dos.h> #include<graphics.h>

void main(void) { char choice; /--variable for input choice--/ int gdriver =DETECT, gmode; /--select driver & mode--/ float red1=100,stan=90,endan=91,mred=80,hred=50,mstar=90,mend=92,hstar=60,hend=63; int md=300,sd=17,hd=1,red=90; struct time t; gettime(&t); stan=stan-(t.ti_sec6); stan=stan-16; endan=stan+1; mstar=mstar-(t.ti_min6); mstar=mstar-2; mend=mstar+2; hstar=hstar-(t.ti_hour30); hstar=hstar-(t.ti_min0.1)+14; hend=hstar+3; clrscr(); initgraph(&gdriver, &gmode, "c:\\TURBOC3/BGI/"); //Change as per your turbo C Graphics Path /--initialized driver--/ setfillstyle(SOLID_FILL,WHITE); bar(0,0,getmaxx(),getmaxy()); setfillstyle(SOLID_FILL,BLUE); // bar(3,1,635,17); setfillstyle(SOLID_FILL,LIGHTBLUE); setcolor(RED); outtextxy(getmaxx()/2-10,130,"12"); outtextxy(210,getmaxy()/2,"9"); outtextxy(getmaxx()/2-10,340,"6"); outtextxy(420,getmaxy()/2,"3"); circle(getmaxx()/2,getmaxy()/2,red1+11); setcolor(WHITE);

while(!kbhit()) { gettime(&t); gotoxy(3,10); printf("time is: %2d:%02d:%02d.%02d\n",t.ti_hour, t.ti_min, t.ti_sec, t.ti_hund); setfillstyle(SOLID_FILL,LIGHTBLUE); fillellipse(getmaxx()/2,getmaxy()/2,red1,red1); setcolor(YELLOW); outtextxy(280,getmaxy()/2-50,"Subu Watch"); setcolor(WHITE); setfillstyle(SOLID_FILL,RED); pieslice(getmaxx()/2,getmaxy()/2,stan,endan,red); pieslice(getmaxx()/2,getmaxy()/2,mstar,mend,mred); pieslice(getmaxx()/2,getmaxy()/2,hstar,hend,hred); delay(1000); setfillstyle(SOLID_FILL,LIGHTGREEN); setcolor(YELLOW); outtextxy(280,getmaxy()/2-50,"Subu Watch"); setcolor(WHITE); pieslice(getmaxx()/2,getmaxy()/2,stan,endan,red); pieslice(getmaxx()/2,getmaxy()/2,mstar,mend,mred); pieslice(getmaxx()/2,getmaxy()/2,hstar,hend,hred); stan=stan-6; endan=endan-6;

mstar=mstar-0.1; mend=mend-0.1; hstar=hstar-(0.1/60); hend=hend-(0.1/60);

} getch(); } ```

π
TechNHIT STEM Faculty
Department of Applied Mathematics & Physics
Making Analogue Clock with C-Language using Graphics | TechNHIT 10+2 STEM Lab | TechNHIT