# A challange

Show 80 post(s) from this thread on one page
Page 1 of 3 123 Last
• 11-01-2008
Ahmed29
A challange
My teacher gave the whole class a challenge that
" Input date month and year and u have to find out the day of that given date . The year should be greater then 1800 " so any help he said you can take any help wether from friend google or anyone and if its done have to submit it in 6 hours so please help me out :)
• 11-01-2008
laserlight
• 11-01-2008
execute
Do you mean find out the days from month and year?

Well that's not too hard is it...

A year is 365 days. A month is usually 30 days. Of course you can be a bit specific by mapping certain months into a function that returns how many days.
• 11-01-2008
Akkernight
So the user inputs a date, and the program tells the person what day that date is? Like, Friday or something?
If that's the purpose of it, then wouldn't it be crazy to go back to 1800?
• 11-01-2008
Ahmed29
yup time is running out and no clue how to do it :( from 1800 up till 2000
• 11-01-2008
stevesmithx
Quote:

yup time is running out and no clue how to do it from 1800 up till 2000
Google using the term "lewis carroll algorithm"
• 11-01-2008
cpjust
Quote:

Originally Posted by execute
A year is 365 days. A month is usually 30 days.

A year is about 365.25 days because every 4 years the days in a year are 366 instead of 365.
The number of days in a month are: 31, (28 or 29), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
So since 7/12 months are 31 days, I'd say a month is "usually" 31 days.
• 11-01-2008
Elysia
Quote:

Originally Posted by cpjust
So since 7/12 months are 31 days, I'd say a month is "usually" 31 days.

I would say a month is about 30 days, since 365 / 12 ~= 30.42 :)
• 11-01-2008
Dae
Uh, challenge you say.. you could at least attempt it and show what you've got.

Some guy just posted something like that: http://cboard.cprogramming.com/showthread.php?t=108659
• 11-01-2008
cpjust
Quote:

Originally Posted by Elysia
I would say a month is about 30 days, since 365 / 12 ~= 30.42 :)

365.25/12 = ~30.4375 on my calculator.
But I said "usually" which is like the mean number, not "about" which is like the average number.
• 11-01-2008
whiteflags
You mean the mode, the most recurring number(s) in a series. The mean is the average.
• 11-01-2008
laserlight
Quote:

Originally Posted by citizen
You mean the mode, the most recurring number(s) in a series. The mean is the average.

Gah, they are just different ways of computing an "average".
• 11-01-2008
BobS0327
• 11-01-2008
cpjust
Quote:

Originally Posted by citizen
You mean the mode, the most recurring number(s) in a series. The mean is the average.

Oops, that's right. Median is what I meant. Too many damn words to choose from. :p
• 11-01-2008
BobS0327
Quote:

```#include <stdio.h> int DayOfWeek(int iYear, int iMonth, int iDay) {     int iT[] = {0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4};     iYear -= iMonth < 3;     return (iYear + iYear/4 - iYear/100 + iYear/400 + iT[iMonth-1] + iDay) % 7; } int main(void) { char *pDay[] = {"Sunday", "Monday",                 "Tuesday", "Wednesday",                 "Thursday", "Friday",                 "Saturday"};     printf("Day of week is %s\n",pDay[DayOfWeek(2008, 11, 16)]);     return 0; }```