Challenge from Harsh

Discussion in 'C' started by harsh_illusion, Jul 27, 2004.

  1. harsh_illusion

    harsh_illusion New Member

    Joined:
    Jul 24, 2004
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    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 )
     
  2. alok

    alok New Member

    Joined:
    Jul 24, 2004
    Messages:
    127
    Likes Received:
    2
    Trophy Points:
    0
    Occupation:
    S/W Engg
    Home Page:
    http://www.thatsalok.com
    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
     
  3. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,009
    Likes Received:
    203
    Trophy Points:
    63
    Occupation:
    Senior Support Engineer
    Location:
    England
    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.
     
  4. elec.shabnam

    elec.shabnam New Member

    Joined:
    Feb 13, 2008
    Messages:
    102
    Likes Received:
    0
    Trophy Points:
    0
    i feel this is a real good challenge for students like me ,to increase our ability
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice