C - Operators and Expressions Questions and Answers

Practice Mode
Showing 10 of 65 questions
Q61
 Which of the following expressions will correctly swap two integers without using a temporary variable ?
  • A (x ^ = y), (y^=x)
  • B (x=y), (y = x)
  • C (x ^ = y), (y ^ = x), x ^ = y)
  • D x^=(y^x)
Answer: Option C
Q62
 What is the correct and fully portable way to obtain the most significant byte of an unsigned integer x ?
  • A x & & 0xFF00
  • B x >> 24
  • C x >> (CHAR - BIT * (sizeof(int)-3))
  • D x >> (CHAR _ BIT * (sizeof (int)-1))
Answer: Option D
Q63
 What is the value of the following expression ? i = 1; i << 1 %2
  • A 2
  • B -2
  • C 1
  • D 0
Answer: Option A
Q64
 For the following statements find the values generated for p and q ?  int p = 0, q = 1; p = q++; p = ++q p = q--; p = - - q; The value of p and  q are
  • A 1, 1
  • B 0, 0
  • C 3, 2
  • D 1, 2
Answer: Option A
Q65
 Which of the following is a better approach to do the operation i = i * 16;?
  • A multiply i by 16 and keep it
  • B shift left by 4 bits
  • C add i 16 times
  • D none of the above
Answer: Option B
Questions and Answers for Competitive Exams Various Entrance Test