Like Tree1Likes
  • 1 Post By camel-man

Impossible ! (H.E.L.P)

This is a discussion on Impossible ! (H.E.L.P) within the C Programming forums, part of the General Programming Boards category; im trying to make this.. Code: #include<stdio.h> int main() { int Year; int FirstDay; int Month; int Leap_Year; int Normal_Year; ...

  1. #1
    Registered User
    Join Date
    Oct 2012
    Posts
    8

    Unhappy Impossible ! (H.E.L.P)

    im trying to make this..Name:  g.jpg
Views: 221
Size:  35.4 KB

    Code:
    #include<stdio.h>
    int main()
    {
        int Year;
        int FirstDay;
        int Month;
        int Leap_Year;
        int Normal_Year;
        int weekday;
        int startday;
        int daycount;
        int days;
        
        
        printf("Input Year:");
        scanf("%d", &Year);
        printf("Input first day of the year as a number:");
        scanf("%d", &FirstDay);
        printf("Input Month to Display:");
        scanf("%d", &Month);
        
        Normal_Year = (((Year-1)*365) + (Year-1/4) - (Year-1/100) + (Year-1/400) + 1)%7;
        Leap_Year = ((Year-1)*365 + (Year-1/4) - (Year-1/100) + (Year-1/400))%7;
        
        if (Month=1)
            printf("January %d", Year);
        else if (Month=2)
            printf("February %d", Year);
        else if (Month=3)
            printf("March %d", Year);
        else if (Month=4)
            printf("April %d", Year);
        else if (Month=5) 
            printf("May %d", Year);
        else if (Month=6)
            printf("June %d",Year);
        else if (Month=7)
            printf("July %d", Year);
        else if (Month=8)
            printf("August %d", Year);
        else if (Month=9)
            printf("September %d", Year);
        else if (Month=10)
            printf("October %d", Year);
        else if (Month=11) 
            printf("November %d", Year);
        else if (Month=12)
            printf("December %d", Year);
        else 
            printf("PAmay may!");
        
        printf("\nResults:\n");    
        printf("\nSun\tMon\tTue\tWed\tThu\tFri\tSat\n");
        printf("\n---\t---\t---\t---\t---\t---\t---\n");
        
        for (weekday = 0; weekday <= startday; weekday++)
            printf(" ");
        if(Month==1 || Month==3 || Month==5 || Month==7 || Month==8 || Month==10 || Month==12)
             days=31;
        else if(Month==4 || Month==6 || Month==9 || Month==11)
             days=30;
        else if((Year%100!=0 && Year%4==0) || Year%400==0)
             days=29;
        else
             days=28;
            
        for    (daycount = 1; daycount <= days; daycount++)
            {
                if(weekday > 6)
                {
                    printf("\n");
                    weekday = 1;
                }
                
                else 
                    weekday++;
                    printf("%3d", daycount);
        return 0;
    }
    }
    tell me what is wrong O_O

  2. #2
    Registered User camel-man's Avatar
    Join Date
    Jan 2011
    Location
    Under the moon
    Posts
    643
    Well for one thing check your if else statements.... You need to use == NOT =
    stahta01 likes this.

  3. #3
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Please work it the other way around - you tell US what's wrong with the program, and we'll try to help you fix it. You obviously KNOW what's wrong, because you had to test it out.

    So share - it really helps quickly focus everyone, on the same problem.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. This seemed impossible!Can anyone help??
    By nesir in forum C Programming
    Replies: 23
    Last Post: 08-22-2006, 02:23 AM
  2. Doing the impossible!!
    By FireHead in forum C Programming
    Replies: 2
    Last Post: 02-02-2006, 10:33 AM
  3. an impossible bug
    By ... in forum C++ Programming
    Replies: 2
    Last Post: 10-19-2003, 05:26 PM
  4. 0% probability == impossible?
    By Silvercord in forum A Brief History of Cprogramming.com
    Replies: 49
    Last Post: 09-01-2003, 04:48 PM
  5. Impossible
    By krappykoder in forum C++ Programming
    Replies: 17
    Last Post: 11-01-2002, 03:26 PM

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