Write a Program to implement Digital Clock.

 

Write a Program to implement Digital Clock.


  1. #include<stdio.h>  
  2. #include<conio.h>  
  3. #include<graphics.h>  
  4. #include<dos.h>  
  5.   
  6. struct time t;  
  7. void display(int,int,int);  
  8. void main()  
  9. {  
  10.     int i=0,gd=DETECT,gm,hr,min,sec;  
  11.     clrscr();  
  12.     initgraph(&gd,&gm,"c:\\turboc3\\bgi");  
  13.     setcolor(GREEN);  
  14.     settextstyle(4,0,7);  
  15.   
  16.     while(!kbhit())  
  17.     {  
  18.        gettime(&t);  
  19.        hr=t.ti_hour;  
  20.        min=t.ti_min;  
  21.        sec=t.ti_sec;  
  22.        i++;  
  23.   
  24.        display(100,100,hr);  
  25.        display(200,100,min);  
  26.        display(300,100,sec);  
  27.               sound(400);  
  28.        delay(30);  
  29.        nosound();  
  30.        delay(930);  
  31.        cleardevice();  
  32.     }  
  33.     getch();  
  34. }  
  35. void display(int x,int y,int num)  
  36. {  
  37.   
  38.      char str[3];  
  39.      itoa(num,str,10);  
  40.   
  41.      settextstyle(4,0,7);  
  42.   
  43.      outtextxy(180,100,":");  
  44.      outtextxy(280,100,":");  
  45.      outtextxy(x,y,str);  
  46.   
  47.      rectangle(90,90,380,200);  
  48.      rectangle(70,70,400,220);  
  49.   
  50.      outtextxy(90,250,"Digital Clock");  
  51. }  

Output

Computer Graphics Programs

Post a Comment

Previous Post Next Post