Hey guys ,
I need some help in writing a C code for a calendar problem.
I need to write a code to find the day of the week if the month and year are entered by the user.
Not able to get the logic for it.
I need this as soon as possible..
Please help me out with this

functions and structure in time.h will give you that information.

  1. First put the day, month and year in a struct tm structure. Then call mktime() to populate the rest of the structure. tm_wday contains the day of the week.

Todays date modulo 7 = day of week.
0 = Sunday 6 = Saturday.

nice try, but that doesn't work. Example: Jan 1 -- 1%7 == 1, and we all know that the first of the month does not always fall on a Monday.

most systems that I work with return the system date as some form of julian date.
1/1/2011 returns 76705. 76705 mod 7 = 6 or Saturday.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.