TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
C Program to know Day by giving Date Input
anuj tiwari
Sep 22
2015
Code
779
0
1
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
expand
Find_Day.rar
#include < stdio.h >
#include < conio.h >
void
main() {
int
a, b, c, d, e, f, g, h;
clrscr();
printf(
"Enter the date like(1 to 31):\t"
);
scanf(
"%d"
, & d);
printf(
"\nEnter the month like(1 to 12):\t"
);
scanf(
"%d"
, & a);
printf(
"\nEnter the year like(1996):\t"
);
scanf(
"%d"
, & b);
printf(
"\nYour entered date is:%d-%d-%d"
, d, a, b);
printf(
"\n"
);
c = (14 - a) / 12;
e = b + 4800 - c;
f = a + 12 * c - 3;
g = (d + ((153 * f + 2) / 5) + 365 * e + (e / 4) - (e / 100) + (e / 400) - 32045) % 7;
h = g - 2;
//printf("%d",h);
printf(
"\nDay on this date:\t"
);
switch
(h) {
case
1:
printf(
"MONDAY"
);
break
;
case
2:
printf(
"TUESDAY"
);
break
;
case
3:
printf(
"WEDNESDAY"
);
break
;
case
4:
printf(
"THURSDAY"
);
break
;
case
-2:
printf(
"FRIDAY"
);
break
;
case
-1:
printf(
"SATURDAY"
);
break
;
case
0:
printf(
"SUNDAY"
);
break
;
default
:
printf(
"\nInvalid application error.."
);
}
getch();
}
C
Day
Date