C Sharp Operators Questions and Answers
In C# programming, operators are fundamental elements used to perform arithmetic, logical, comparison, and bitwise operations. Mastering programming questions and answers on C# operators is crucial for interviews at TCS, Infosys, and Wipro. Understanding operator precedence, associativity, and overloading enhances your coding accuracy and debugging skills. These C programming MCQ and C# operator questions test your ability to manipulate data efficiently. Practice programming interview questions with answers to strengthen your C# fundamentals for competitive coding assessments and placement tests.
Study operators and assignments in C#. Also explore C# control instructions and C# arrays
C Sharp Operators
Showing 10 of
19 questions
1. Which of the following are the correct ways to increment the value of variable a by 1? 1. ++a++; 2. a += 1; 3. a ++ 1; 4. a = a +1; 5. a = +1;
- 1, 3
- 2, 4
- 3, 5
- 4, 5
2. What will be the output of the C#.NET code snippet given below? byte b1 = 0xF7; byte b2 = 0xAB; byte temp; temp = (byte)(b1 & b2); Console.Write (temp + " "); temp = (byte)(b1^b2); Console.WriteLine(temp);
- 163 92
- 92 163
- 192 63
- 0 1
4. Which of the following are NOT Relational operators in C#.NET? >= != Not <= <>=
- 1, 3
- 2, 4
- 3, 5
- 4, 5
6. Which of the following statements is correct about the C#.NET code snippet given below? int d; d = Convert.Tolnt32( !(30 < 20) );
- A value 0 will be assigned to d.
- A value 1 will be assigned to d.
- A value -1 will be assigned to d.
- The code reports an error.
7. Which of the following is the correct output for the C#.NET code snippet given below? Console.WriteLine(13 / 2 + " " + 13 % 2);
- 6.5 1
- 6.5 0
- 6 0
- 6 1
8. Which of the following statements are correct about the Bitwise & operator used in C#.NET? The & operator can be used to Invert a bit. The & operator can be used to put ON a bit. The & operator can be used to put OFF a bit. The & operator can be used to check whether a bit is ON. The & operator can be used to check whether a bit is OFF.
- 1, 2, 4
- 2, 3, 5
- 3, 4
- 3, 4, 5
9. Which of the following are Logical operators in C#.NET? && || ! Xor %
- 1, 2, 3
- 1, 3, 4
- 2, 4, 5
- 3, 4, 5
10. 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?
- if ((n&16) == 16) Console.WriteLine("Third bit is ON");
- if ((n&8) == 8) Console.WriteLine("Third bit is ON");
- if ((n ! 8) == 8) Console.WriteLine("Third bit is ON");
- if ((n ^ 8) == 8) Console.WriteLine("Third bit is ON");