PAR NUMBERS

  • Thread starter Thread starter Jose Fernandez
  • Start date Start date
J

Jose Fernandez

Hello friends.
I have trying to figure out how to identify a Par number (divisible by 2)
but I couldn't find any method.

Does anyone knows how to "know" if an integer is a Par number??
thanks in advance

Jose
 
Jose,

An easy way is to use the modulus operator (%) like this:

if (number % 2 == 0)
{
// Number is even/par
}
else
{
// Number is odd.
}

Hope this helps.
 
THANKS
IT WORKED

Nicholas Paldino said:
Jose,

An easy way is to use the modulus operator (%) like this:

if (number % 2 == 0)
{
// Number is even/par
}
else
{
// Number is odd.
}

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Jose Fernandez said:
Hello friends.
I have trying to figure out how to identify a Par number (divisible by 2)
but I couldn't find any method.

Does anyone knows how to "know" if an integer is a Par number??
thanks in advance

Jose
 
Back
Top