Friday, September 5, 2008

C# Program-Use bitwise AND to determine if a number is odd.

using System;

class IsOdd {
public static void Main() {
ushort num;

num = 10;

if((num &1)==1)
Console.WriteLine(" This won't display.");

num = 11;

if((num & 1) == 1)
Console.WriteLine( num + " is odd.");

}
}

0 comments: