Saturday, March 24, 2012

windows batch program: need to test if a number is even or not even

Already did some research in the web with google.

But informations about batch and mathematical operations are very rarely.

I guess you can do that by using the modulo operator but I didnt figure out the correct syntax and
how to use this operator to solve my requirement!

thanks in advance,

mulata

if ( myInteger % 2 == 0 )

{

// Even

}

else

{

// Odd

}


Or, in VB:

if (myIntegermod 2) = 0 then

'even

else

'odd

end if

0 comments:

Post a Comment