# include int main ( ) { int d; int m; int y; printf ( "Enter date as m/d/y: " ); // // Notice that I include the slashes in the input format! // scanf ( "%i/%i/%i", &m, &d, &y ); // // We really ought to make sure that M and D are legal! // // // If D/M is the last day of the year, we've got big changes! // if ( d == 31 && m == 12 ) { d = 1; m = 1; y = y + 1; } // // Otherwise, if D is the last day of M, we've got medium changes! // I could have jammed the following three IF statements into one, // but it would be impossible to read. // // This check assumes we are NOT in a leap year! // else if ( d == 28 && m == 2 ) { d = 1; m = m + 1; } else if ( d == 30 && ( m == 4 || m == 6 || m == 9 || m == 11 ) ) { d = 1; m = m + 1; } else if ( d == 31 && ( m == 1 || m == 3 || m == 5 || m == 7 || m == 8 || m == 10 ) ) { d = 1; m = m + 1; } // // Otherwise, it's easy! // else { d = d + 1; } printf ( "Next day is %i/%i/%i\n", m, d, y ); return 0; }