Beruflich Dokumente
Kultur Dokumente
“DIGITAL CLOCK”
Submitted by
Group number: 1
Certificate
Staff In-charge:
Kavitha
Asst. Professor
Dept. of CS&E
Bangalore Institute of Technology
Bangalore
Group Members
USN Name
CONTENTS
1.1 Introduction 1
1.
1.2 Problem Statement 2
3. Output Screenshot 6
4. Conclusion 7
INTRODUCTION
Clock is one of the most important component of our day to day life. It
can be used for various purpose like:-
1)This program can be used to take the count of the time.
2)This program can also be used as timers essential in online exams,etc.
3)This program can also be used in places where the count of second
matters, like in races.
4)This program can also be used in the day-to-day life.
Without clock the daily work is not possible while no one will be able to
take the count of time.
With the help of digital clock one can also access to the day and date in
addition with the time. This additional feature is very important as it
saves one from checking calendars on a regular note.
___________
Problem Statement
It also takes the count of leap year and we can even access to the past
year for any kind of information.This application is important in many
fields like investigation and fields where we need to enter date of birth.
________________
Source Code
#include<stdio.h>
#include<conio.h>
#include<dos.h>
#define True 1
#define False 0
void main()
{
int days_in_month[]={0,31,28,31,30,31,30,31,31,30,31,30,31};
int h=0,m=0,s=0,day=0,date,month,year;
printf("Enter a year");
scanf("%d",&year);
if(year%4==False&&year%100!=False||year%400==False)
{
days_in_month[2]=29;
}
else
{
days_in_month[2]=28;
}
printf("Enter the date and month");
scanf("%d%d",&date,&month);
printf("Enter the time in hh:mm:ss");
scanf("%d%d%d",&h,&m,&s);
start:;
for(year;year<2050;year++)
{
for(month=1;month<12;month++)
{
for(day=0,date;day<7,date<days_in_month[1];day++,date++)
{
for(h;h<24;h++)
{
for(m;m<60;m++)
{
for(s;s<60;s++)
{
printf("%d:%d:%d\n",h,m,s);
delay(1000);
clrscr();.
printf("\n");
if(day==0)
printf("Sunday");
else if(day==1)
printf("Monday");
else if(day==2)
printf("Tuesday");
else if(day==3)
printf("Wednesday");
else if(day==4)
printf("Thrusday");
else if(day==5)
printf("Friday");
else if(day==6)
printf("Saturday");
else
printf("wrong choice");
printf("\n");
day=0;
if(month==1)
printf("%d/Jan/%d\n",date,year);
else if(month==2)
printf("%d/Feb/%d\n",date,year);
else if(month==3)
printf("%d/Mar/%d\n",date,year);
else if(month==4)
printf("%d/Apr/%d\n",date,year);
else if(month==5)
printf("%d/May/%d\n",date,year);
else if(month==6)
printf("%d/June/%d\n",date,year);
else if(month==7)
printf("%d/July/%d\n",date,year);
else if(month==8)
printf("%d/Aug/%d\n",date,year);
else if(month==9)
printf("%d/Sept/%d\n",date,year);
else if(month==10)
printf("%d/Oct/%d\n",date,year);
else if(month==11)
printf("%d/Nov/%d\n",date,year);
else if(month==12)
printf("%d/Dec/%d\n",date,year);
else
printf("wrong choice");
} s=0;
}m=0;.
}h=0;
}day=0;date=1;
}month=1;
}
goto start;
getch();
}
________________________
Output Screenshots
________________
Conclusion
The clock will run for indefinite time with ‘second’ changing after
each second and ‘minute’ will change once the second count reaches
60.After that the ‘hour’ will change after the minute count reaches
60 similarly days and date will also change after 24 hours.
By using the features in the code we can use it as a timer and also
other places where we need to look into past years.
___________________