Question: Find the day of the week of a given date?

Solution: The following code snippet shows how to get the day of week from the given date.
dayofweek ( int yy, int mm, int dd )
{
/*Monday = 1 and Sunday = 0 */
/* month number >= 1 and <= 12, yy > 1752 or so */
static int arr[ ] = { 0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4 } ;
yy = yy – mm < 3 ;
return ( yy + yy / 4 – yy / 100 + yy / 400 + arr[ mm - 1] + dd ) % 7 ;
}
void main( )
{
printf ( “\n\n\nDay of week : %d “, dayofweek ( 2002, 5, 18 ) ) ;
}