|
-
Sep 20th, 2002, 03:06 PM
#1
Thread Starter
Lively Member
C: is a number even!!
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
-
Sep 20th, 2002, 03:08 PM
#2
Frenzied Member
if(num%2==0)
//then the number's even
-
Sep 20th, 2002, 03:11 PM
#3
Thread Starter
Lively Member
-
Sep 23rd, 2002, 12:31 PM
#4
Frenzied Member
just use macros like
Code:
#define iseven(c) (c%2==0)
usage
Code:
int a;
........
if (iseven(a) ) ..........;
-
Sep 24th, 2002, 06:49 AM
#5
(num & 0x1) would be faster, accomplishing the same.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Sep 25th, 2002, 03:40 AM
#6
Hyperactive Member
Now that's a smart one... have to keep that one in mind!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|