Digital Clock C++ Coding

#include<stdio.h>
#include<conio.h>
#include <unistd.h>
#include <windows.h>
void gotoxy(int x, int y)
{
    COORD coord;
    coord.X = x;
    coord.Y = y;
    SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
}
int main()
{
int Hr,Mn,Sc,stay;
printf(“Enter a hours”);
scanf(“%d”,&Hr);
printf(“Enter a Mnt”);
scanf(“%d”,&Mn);
printf(“Enter a sec”);
scanf(“%d”,&Sc);
gotoxy(40,11);
printf(“Lunar Digital Clock”);
gotoxy(40,12);
printf(“=====================”);
gotoxy(45,13);
printf(“Hr : Mn : Sc”);
gotoxy(40,15);
printf(“=====================”);
clockloop:
gotoxy(45,14);
printf(“%d : %d : %d “,Hr,Mn,Sc);
Sc++;
sleep(1);
if(Sc<60) goto clockloop;
else
Sc=0;
Mn++;
if(Mn<60) goto clockloop;
else
Sc=0;
Mn=0;
Hr++;
if(Hr<12) goto clockloop;
else 
Sc=0;
Mn=0;
Hr=1;
goto clockloop;
}

Leave a Reply

Your email address will not be published. Required fields are marked *