thanks

0

0

Below is some code I wrote w/ pradeep's help. It was an assignment in a book I'm going through.

---------------------------------------------------------------------------------------------

---------------------------------------------------------------------------------------------

Code:

#include<stdio.h> main() { int month, year, n, leap, notLeap; printf("\n\nEnter a month and year: "); scanf("%d %d", &month, &year); if(year % 400 == 0 || (year % 100 != 0 && year % 4 == 0)) year = leap; else year = notLeap; if (year == leap && month == 2) n = 29; if (year == notLeap && month == 2) n = 28; if (month == 1) n = 31; if (month == 3) n = 31; if (month == 4) n = 30; if (month == 5) n = 31; if (month == 6) n = 30; if (month == 7) n = 31; if (month == 8) n = 31; if (month == 9) n = 30; if (month == 10) n = 31; if (month == 11) n = 30; if (month == 12) n = 31; printf("\n\nThere are %d days in that month.", n); getch(); return; }

*Last edited by shabbir; 14Feb2011 at 11:59.. Reason: Code blocks*

0

Quote:

The logic is that the year is either divisible by both 100 and 4 , OR its only divisible by 4 not by hundred

To say that a number is divisible by 100 and 4, or 100 or 4, is that same as saying a number is divisible by 4.

That is: (A ^ B) v (A ^ !B) = A ^ (B v !B) = A.

This is the same logic that makes all those ads so hilarious: "You can make up to $50,000 a year, or more!" So I guess the only amount you

*can't*make is $50,000!

Sorry, anal logician here

-Plast