1.

Suppose n is a variable of the type Byte and we wish, to check whether its fourth bit (from right) is ON or OFF. Which of the following statements will do this correctly?

A. <pre><code class="csharp">if ((n&amp;16) == 16) Console.WriteLine("Fourth bit is ON");</code></pre>
B. <pre><code class="csharp">if ((n&amp;8) == 8) Console.WriteLine("Fourth bit is ON");</code></pre>
C. <pre><code class="csharp">if ((n ! 8) == 8) Console.WriteLine("Fourth bit is ON");</code></pre>
D. <pre><code class="csharp">if ((n ^ 8) == 8) Console.WriteLine("Fourth bit is ON");</code></pre>
E. <pre><code class="csharp">if ((n ~ 8) == 8) Console. WriteLine("Fourth bit is ON");</code></pre>
Answer» C. <pre><code class="csharp">if ((n ! 8) == 8) Console.WriteLine("Fourth bit is ON");</code></pre>


Discussion

No Comment Found

Related MCQs