English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

its either TRUE or False , i tried n/2 then if decimal =.0 then it is even, if it is <>.0 it is odd. or if you have other means to prove that a number is even or odd , it would help , OR maybe you could help me build a flowchart :) but really , i want to learn this !
thank you

2006-07-03 00:31:52 · 6 answers · asked by Jacob R 1 in Computers & Internet Programming & Design

6 answers

if n MOD 2 = 0 then even else odd

if you think you might get input outside of the natural numbers then

if (n > 0 and decimal = .0) then (if n MOD 2 =0 then even else odd)

2006-07-03 00:36:30 · answer #1 · answered by alia_vahed 3 · 1 0

Try MOD 2
If answer = 0 then even
If andwer = 1 then odd

2006-07-03 00:37:34 · answer #2 · answered by peter r 2 · 0 0

I'm going to use c#, java c c++ shold be just about the same
private bool iseven(int num)
{
bool retval =false;
if((x%2)==0)
retval =true;
return retval;
}

2006-07-03 02:37:45 · answer #3 · answered by ralphd42 2 · 0 0

you could use

if int(N/2) = N/2 then "its even" else "its odd"

or if you are familiar with modulo arithmetic then simply use

if N mod 2 = 0 then "its even" else "its odd"

2006-07-03 00:37:53 · answer #4 · answered by Ivanhoe Fats 6 · 0 0

any number continuously divided by two should give 1 for example 2/2=2,4/2=2/2=1....got it

2006-07-03 00:41:24 · answer #5 · answered by vedha 2 · 0 0

try this:
if (n & 0x1)
the number is odd
else
the number is even

2006-07-03 06:02:15 · answer #6 · answered by justme 7 · 0 0

fedest.com, questions and answers