using System;
class MakeOdd {
public static void Main() {
ushort num;
ushort i;
for(i = 1; i <= 10; i++) {
num = i;
Console.WriteLine("num: " + num);
num = (ushort) (num | 1); // num | 0000 0001
Console.WriteLine("num after turning on bit zero: "
+ num + "\n");
}
}
}
Friday, September 5, 2008
C# program: Use bitwise OR to make a number odd using bitwise '|'.
Posted by Nanya at 6:58 AM
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment