Testing if a number is an integer

Zoq (3)
I have searched for quite some time now and I cannot figure out how to input a year like 2000 and divide it by 4. Then test to see if it is an integer or a float number.
maeriden (244)
Do you want to check for leap years? In that case you can use the modulo operator and check if the result is equal to 0
Zoq (3)
I am fairly new to programming. How exactly would I do that?
maeriden (244)
The modulo operator in C is %. It gives the remainder in a division between integers (doesn't work with floats at all)
For example 7 % 3 == 1. The quotient is 2 and the remainder is 1

This pseudocode is copypasted from wikipedia
if year modulo 400 is 0 then
is_leap_year
else if year modulo 100 is 0 then
not_leap_year
else if year modulo 4 is 0 then
is_leap_year
else
not_leap_year
palauan73 (8)
You would want x % y = 0, meaning the remainder of x / y is 0 meaning that the final result is a whole number or an integer.
Zoq (3)
Alright thank you guys. I got the program working. And i learded what a modulo operator is!
Registered users can post here. Sign in or register to post.