
Originally Posted by
Minardi
Edit:
"Now if you wanted to say for example...
if ((num / 4) > 0)
That would be a condition, it would return a boolean and therefor be compliant. "
What I would like to say is if the year can be divided by 4, and if it can also be divided by 100 and 400, th it's a leap year.. But I'm not quire sure if that's correct!
Code:
if (year % 4 == 0 && year % 100 == 0 && year % 400 == 0)
{
is leap year
}
% = Modulus. It's like divison except it returns the remainder rather than the division. If x modulus y = 0 then x is cleanly divisible by y.
&& = AND. Joins two conditionals together inside an if or while etc.
eg. if (x && y). If x = true and y = true, then the statement returns true. If one of them is false or both of them are false, then the statement returns false
To do it like you had before would just be:
Code:
if (year % 4 == 0)
if (year % 100 == 0)
if (year % 400 == 0)
{
code
}