A challange

This is a discussion on A challange within the C++ Programming forums, part of the General Programming Boards category; My teacher gave the whole class a challenge that " Input date month and year and u have to find ...

  1. #1
    Registered User
    Join Date
    Oct 2008
    Posts
    18

    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

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,743
    I am not your friend (yet?), so try Google.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Apr 2006
    Posts
    137
    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.
    ★ Inferno provides Programming Tutorials in a variety of languages. Join our Programming Forums. ★

  4. #4
    Hail to the king, baby. Akkernight's Avatar
    Join Date
    Oct 2008
    Location
    Faroe Islands
    Posts
    717
    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?
    Currently research OpenGL

  5. #5
    Registered User
    Join Date
    Oct 2008
    Posts
    18
    yup time is running out and no clue how to do it from 1800 up till 2000

  6. #6
    and the hat of copycat stevesmithx's Avatar
    Join Date
    Sep 2007
    Posts
    498
    yup time is running out and no clue how to do it from 1800 up till 2000
    Google using the term "lewis carroll algorithm"
    Not everything that can be counted counts, and not everything that counts can be counted
    - Albert Einstein.


    No programming language is perfect. There is not even a single best language; there are only languages well suited or perhaps poorly suited for particular purposes.
    - Herbert Mayer

  7. #7
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Quote Originally Posted by execute View Post
    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.
    "I am probably the laziest programmer on the planet, a fact with which anyone who has ever seen my code will agree." - esbo, 11/15/2008

    "the internet is a scary place to be thats why i dont use it much." - billet, 03/17/2010

  8. #8
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,614
    Quote Originally Posted by cpjust View Post
    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
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  9. #9
    Dae
    Dae is offline
    Deprecated Dae's Avatar
    Join Date
    Oct 2004
    Location
    Canada
    Posts
    1,034
    Uh, challenge you say.. you could at least attempt it and show what you've got.

    Some guy just posted something like that: New member just saying hi, along with my first question :)
    Warning: Have doubt in anything I post.

    GCC 4.5, Boost 1.40, Code::Blocks 8.02, Ubuntu 9.10 010001000110000101100101

  10. #10
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Quote Originally Posted by Elysia View Post
    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.
    "I am probably the laziest programmer on the planet, a fact with which anyone who has ever seen my code will agree." - esbo, 11/15/2008

    "the internet is a scary place to be thats why i dont use it much." - billet, 03/17/2010

  11. #11
    Registered User whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    7,706
    You mean the mode, the most recurring number(s) in a series. The mean is the average.

  12. #12
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,743
    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".
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  13. #13
    Registered User
    Join Date
    Mar 2005
    Location
    Mountaintop, Pa
    Posts
    1,059

  14. #14
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Quote Originally Posted by citizen View Post
    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.
    "I am probably the laziest programmer on the planet, a fact with which anyone who has ever seen my code will agree." - esbo, 11/15/2008

    "the internet is a scary place to be thats why i dont use it much." - billet, 03/17/2010

  15. #15
    Registered User
    Join Date
    Mar 2005
    Location
    Mountaintop, Pa
    Posts
    1,059
    if its done have to submit it in 6 hours so please help me out
    Time's up. So, here's one possible solution...


    Code:
    #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;
    }

Page 1 of 3 123 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Challange for Cprogramming.com
    By umar7001 in forum C++ Programming
    Replies: 28
    Last Post: 04-15-2007, 08:31 AM
  2. Digit selector... (Mathmatically complex, for some)
    By Axpen in forum C Programming
    Replies: 17
    Last Post: 08-28-2004, 02:58 PM
  3. Stuck on a friend's challange
    By wiresite in forum C++ Programming
    Replies: 32
    Last Post: 04-23-2004, 07:36 AM
  4. Timecard Challange
    By Thantos in forum Contests Board
    Replies: 2
    Last Post: 11-20-2003, 03:12 PM
  5. Chess Challange
    By kosmoludek in forum C Programming
    Replies: 4
    Last Post: 01-12-2003, 03:53 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21