Tuesday, October 4, 2011

Digital clock in C

#include<iostream.h>

#include<conio.h>

#include<dos.h>

#include<stdlib.h>

void main()

{

                int h,s,m,h1,m1,s1;

                clrscr();

                cout<<"Enter hour,minute and second"<<"\n";

                cin>>h>>m>>s;

                h1=h;

                m1=m;

                s1=s;

                while(!kbhit())

                {              if(s1==60)

                                                {

                                                                m1+=1;

                                                                s1=0;

                                                }

                                                if(m1==60)

                                                {

                                                                h1+=1;

                                                                m1=0;

                                                }

                                                if(h1==24)

                                {

                                  h1=0;

                                  m1=0;

                                  s1=0;

                                }

                                                gotoxy(32,12);

                                                cout<<h1<<":";

 

                                                gotoxy(35,12);

                                                cout<<m1<<":";

 

                                                gotoxy(38,12);

                                                cout<<s1;

                                                s1++;

                                                delay(1000);

                                                clrscr();

 

                                }

                                }

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

No comments :

Post a Comment