and the problem is this:Code:#include <stdio.h> main() { int day_code; /* day_code = 0 means the month starts on Sun day_code = 1 means the month starts on Mon day_code = 2 means the month starts on Tues, etc. */ int days_in_month; /* number of days in month currently being printed */ int leap_year = 0; /* 1 means leap year; 0 means no leap year */ int day; /* counter for day of month */ int month; /* month = 1 is Jan, month = 2 is Feb, etc. */ int year; int f; int d; int c; do { printf( "Enter year: " ); scanf( "%d", &year ); } while ( year < 1776 ); if ((year % 400 == 0) || ((year % 4 == 0) && (year % 100 != 0))) { leap_year = 1; } printf( "%d", leap_year ); c = year / 100; d =( year % 100 ) - 1 ; f = 1 + (( 13 * 11 - 1 ) / 5) + d + ( d / 4 ) + ( c / 4 ) -( 2*c ) ; day_code = f % 7; if (leap_year == 1 ) { day_code=day_code-1; } for ( month = 1; month <= 12; month++ ) { switch ( month ) { /* print name and set days_in_month */ case 1: printf( "\n\nJanuary" ); days_in_month = 31; break; case 2: printf( "\n\nFebruary" ); if( leap_year == 1 ) { days_in_month = 29; } else if( leap_year ==0 ) { days_in_month = 28; } break; case 3: printf( "\n\nMarch" ); days_in_month = 31; break; case 4: printf( "\n\nApril" ); days_in_month = 30; break; case 5: printf( "\n\nMay" ); days_in_month = 31; break; case 6: printf( "\n\nJune" ); days_in_month = 30; break; case 7: printf( "\n\nJuly" ); days_in_month = 31; break; case 8: printf( "\n\nAugust" ); days_in_month = 31; break; case 9: printf( "\n\nSeptember" ); days_in_month = 30; break; case 10: printf( "\n\nOctober" ); days_in_month = 31; break; case 11: printf( "\n\nNovember" ); days_in_month = 30; break; case 12: printf( "\n\nDecember" ); days_in_month = 31; break; } printf( "\n\nSun Mon Tue Wed Thu Fri Sat\n" ); /* advance printer to correct position for first date */ for ( day = 1; day <= 1 + day_code * 5; day++ ) { printf( " " ); } /* print the dates for one month */ for ( day = 1; day <= days_in_month; day++ ) { printf( "%2d", day ); if ( ( day + day_code ) % 7 > 0 ) /* before Sat? */ /* move to next day in same week */ { printf( " " ); } else /* skip to next line to start with Sun */ { printf( "\n " ); } } /* set day_code for next month to begin */ day_code = ( day_code + days_in_month ) % 7; } }
output for january:
Code:Enter year: 2008 1 January Sun Mon Tue Wed Thu Fri Sat 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
its one day off please help