Day of the week in year program advanced

This is a discussion on Day of the week in year program advanced within the C Programming forums, part of the General Programming Boards category; Given a date (month, day, and year) display the day of the week on which that date takes/took place and ...

  1. #1
    Registered User
    Join Date
    Jul 2010
    Posts
    2

    Post Day of the week in year program advanced

    Given a date (month, day, and year) display the day of the week on which that date takes/took place and
    the day of the week of January 1st for that year.

    Example Execution :
    Enter the month: 1
    Enter the day: 15
    Enter the year: 2010
    Date: January 1, 2010 Day of week: Friday
    Date: January 15, 2010 Day of week: Friday

    I got the day of the week part done just for the jan 15th , 2010. But i need help displaying the "january 15,2010" or whatever date is entered. ALso I don't have any idea how to do the 1st of the month line or the day of the week for that. PLEASSSE HELLEEPPP! SOS

  2. #2
    Registered User
    Join Date
    Jul 2010
    Posts
    2

    Smile program so far

    Code:
    #include<stdio.h>
    
    
    
    ///////// Global Declarations 
    
    
    
    int main()
    {
            int y;                  /* year */
            int m;                  /* month */
            int d;                  /* date (day) */
            int newdate;            /* day of the week */
    
            printf("Enter the month:");
            scanf("%d", &m);
            printf("Enter the day : ");
            scanf("%d", &d);
            printf("Enter the year:");
            scanf("%d", &y);
    
    
    
             if (m < 3)
                    {
                            m = m + 12;
                            y = y - 1;
                    }
    
    
    
    
    
            newdate = (d + (2 * m) + ((6 * (m + 1)) / 10) + y + (y / 4) -
    
    (y / 100) + (y / 400) + 1) % 7;
    
            switch (newdate)
            {
                    case 0:
                    {
                            puts("Day of week:Sunday.");
                            break;
                    }
                    case 1:
                    {
                            puts(" Day of week : Monday.");
                            break;
                    }
                    case 2:
                    {
                            puts("Day of week : Tuesday");
                            break;
                    }
                    case 3:
                    {
                            puts("Day of week : Wednesday.");
                            break;
                    }
                    case 4:
                    {
                            puts("Day of week : Thursday.");
                            break;
                    }
                    case 5:
                    {
                            puts("Day of week : Friday.");
                            break;
                    }
                    case 6:
                    {
                            puts("Day of week : Saturday.");
                            break;
                    }
                    default:
                    {
                            puts("Day of week : Wrong Date!");
                    }
            }
    
            return 0;

  3. #3
    Registered User
    Join Date
    Oct 2008
    Location
    TX
    Posts
    2,058
    Lookup the manpage of mktime().

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. c program help :>
    By n2134 in forum C Programming
    Replies: 9
    Last Post: 02-06-2010, 12:12 PM
  2. Writing a program to make a calendar
    By Northstar in forum C Programming
    Replies: 17
    Last Post: 11-07-2007, 11:34 AM
  3. function
    By Unregistered in forum C Programming
    Replies: 3
    Last Post: 06-02-2002, 08:38 PM
  4. debug program
    By new_c in forum C Programming
    Replies: 3
    Last Post: 03-18-2002, 11:50 PM
  5. Simplified code
    By soonerfan in forum C Programming
    Replies: 2
    Last Post: 12-05-2001, 03:50 PM

Tags for this Thread


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