how can i check if a number is even in C...is there a function to do so, if so which header file is it in?
Thanks,
Steve
Printable View
how can i check if a number is even in C...is there a function to do so, if so which header file is it in?
Thanks,
Steve
if(num%2==0)
//then the number's even :)
thanks
just use macros like
usageCode:#define iseven(c) (c%2==0)
Code:int a;
........
if (iseven(a) ) ..........;
(num & 0x1) would be faster, accomplishing the same.
Now that's a smart one... have to keep that one in mind!