Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   Challenge from Harsh (http://www.go4expert.com/forums/challenge-from-harsh-t60/)

 harsh_illusion 27Jul2004 15:23

Challenge from Harsh

HI FRNds !

here's a good one for those having interest in C .
Q: create a program to find the Day for any Date of ny Month and ny Year(ny means it can also be 0 or more than 9999) and then after displaying the day the user can browse whole calender ( consequtive months from up & down arrow keys and consequtive Years from left and right arrow keys.)

CONDITION: The Program must be in "Text" mode and the amount of code lines used should be "MINIMUM". Also for representing months and years "strings " should be used not like using 1 to 12 for displaying all the months !

( ONLY C LANGUAGE CAN BE USED )

 alok 27Jul2004 15:47

Re: Challenge from Harsh

hain r u in school or want to complete the college project.
what type of Challenege is this.
hain any way we can try your challenge.tell me the time limit

 xpi0t0s 6Aug2004 16:00

Re: Challenge from Harsh

Impossible to answer in its current form.

Year 0 didn't exist. So if it has 365 or 366 days, it will mess up the order of days in BC or AD depending which way you're doing the calculation.

If it has 364 days, which is an exact multiple of 7, then it might work, but you'll need to find out what month has one fewer day than normal. Will February have 27 days, or will another month be reduced?

The current calendar has only been in force for the last few hundred years. Projecting back before then is a bit pointless (although I suppose means it could print anything without technically being "incorrect")

Actually this "challenge" is a piece of cake. Simply take a known day (e.g. today, Friday Aug 6), convert that into a number of days (doesn't really matter from when), convert your required day into a number of days, subtract it from the known day and take the remainder after dividing by 7. Subtract the result from the number for Friday (e.g. 6), mod the result by 7 and that gives you the day number, which you can convert back into a day name.

So if you pick a day 3503 days from now, that's 500*7+3, and about 10 years, that's clearly going to be a Monday.

 elec.shabnam 26Feb2008 16:49

Re: Challenge from Harsh

i feel this is a real good challenge for students like me ,to increase our ability

 All times are GMT +5.5. The time now is 15:22.