# Thread: "FAQ > How do I... (Level 2) > Work with dates and times" - Queries.

1. ## "FAQ > How do I... (Level 2) > Work with dates and times" - Queries.

Dear experts,

I was browsing through the FAQs when I stumbled on one portion:

Code:
```int leap_year ( int year )
{
return year % 4 == 0 && ( year % 100 != 0 || year % 400 == 0 );
}```
I do not understand the expression. Can it be broken down to a few more lines so that newbies like me can understand? Please?

Thanks.

2. Code:
```int leap_year(int year)
{
if(year % 4 ==0)
{
if(year % 100 != 0 || year % 400 == 0)
return true;
}
}```
ssharish2005

3. if(year % 4 ==0)

...This means if 4 percent of the variable year equals zero.
I hope you know what Percent means:-

Code:
`4/100 * year`
if(year % 100 != 0 || year % 400 == 0)

...And this means if 100 percent of year does not equal zero or 400 percent equals zero return true.

I hope this is helpful

Ps. I'm lying

4. That's not very nice. I'm gonna get Webmaster and have you band.

5. Originally Posted by treenef
if(year % 4 ==0)

...This means if 4 percent of the variable year equals zero.
I hope you know what Percent means:-

Code:
`4/100 * year`
if(year % 100 != 0 || year % 400 == 0)

...And this means if 100 percent of year does not equal zero or 400 percent equals zero return true.

I hope this is helpful

Ps. I'm lying
EDIT: What are you trying to say?

6. Originally Posted by ssharish2005
Code:
```int leap_year(int year)
{
if(year % 4 ==0)
{
if(year % 100 != 0 || year % 400 == 0)
return true;
}
}```
ssharish2005
Thanks. That's sweet.

7. Originally Posted by stevong
Why?
I seriously seriously hope you saw the whited out text in Treenef's post... and I was talking to him, by the way, and it was a joke.

8. Originally Posted by SlyMaelstrom
I seriously seriously hope you saw the whited out text in Treenef's post... and I was talking to him, by the way, and it was a joke.
Haha. yea. I didnt read his post clearly.

I almost fell off my chair when I read his post all over again.

9. So... you do understand what the modulus operator is, right?

10. Originally Posted by SlyMaelstrom
So... you do understand what the modulus operator is, right?
Yes I do.

The intention of this thread is to hope that someone can break down that single line of code into simpler statements in which layman/newbies can understand.

Thanks to ssharish2005.

Code:
`return year % 4 == 0 && ( year % 100 != 0 || year % 400 == 0 );`
Code:
``` 	if(year % 4 ==0)
{
if(year % 100 != 0 || year % 400 == 0)
return true;
}```

11. Originally Posted by stevong
Code:
```int leap_year ( int year )
{
return year % 4 == 0 && ( year % 100 != 0 || year % 400 == 0 );
}```
I do not understand the expression. Can it be broken down to a few more lines so that newbies like me can understand? Please?
Return true if the year is evenly divisible by 4 and {the year is not evenly divisible by 100 or it is evenly divisible by 400}; otherwise return false.

Popular pages Recent additions