In: Electrical Engineering
3. Design a digital watch that allows the user to set and display time.
/*C program to set and display time in a digital clock.*/
 
#include<stdio.h>
#include<conio.h>
#include<math.h>
#include<time.h>
 
void main()
{
    system("clear");       //to clear the output screen
    int hr=0, min=0, sec=0;
 
    while(1)
    {
           system("clear");
         
        printf("time:/n")
        printf("%d,%d,%d",hr,min,sec);
         
         //increase second
        sec++;                 //means sec=sec+1
            if(sec==60){
            min=min+1;        // post increment operation
            sec=0;
        }
        if(min==60){
            hr=hr+1;
            min=0;
        }
        if(hr==24)
        {
            hr=0;
            min=0;
            sec=0;
        }
         
        sleep(1);//to sleep the display if there is activity(wait for 1 second)
    }
                   //no need of using return as we took returning type void
         getch();    // to hold the output screen
}