hello everyone
can i use the statement below to check wether a year is leap or not
the statement is
if((year%100== 0 && year%400==0) || (year%100!=0&&year%4==0))
feb=29;
else
feb=28;
hello everyone
can i use the statement below to check wether a year is leap or not
the statement is
if((year%100== 0 && year%400==0) || (year%100!=0&&year%4==0))
feb=29;
else
feb=28;
Yes, something like that should work just fine.
I assume there is a followup "doesn't work" question coming....
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
excuse me salem what did you mean ?
He's expecting the "other shoe to fall" i.e.:
"I've been trying to get this to work in my assignment, but it just won't give me the right results".
Personally, I like to enclose compound statements like that if statement, in their own seperate parenthesis, so the bug of operator precedence doesn't bite me too often.
Adak
If the year is divisible by 400, then it's also divisible by 100 so you don't need to check both.
do you think just by integrating braces everything is going to be all right
Yes, the shoe event horizon looms large.
Basically, you've asked a "meta" question as a disguise of your real question.
So we just waste a bunch of time pratting about with the obvious until you get around to the real problem which you're facing.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.