ProgrammingVery hardGATE CS · Campus placements

Which of these statements are well defined by the C standard? I. uint8_t x = 255; x = x + 1; leaves x equal to 0. II. int a = INT_MAX; a + 1 yields INT_MIN. III. unsigned int u = 0; u - 1 equals UINT_MAX. IV. sizeof(char) equals 1.

  1. A. I and III only
  2. B. I, III and IV only
  3. C. II and IV only
  4. D. I, II, III and IV

Correct answer: B. I, III and IV only

I, III and IV are defined: unsigned wraparound is modular, and sizeof(char) is 1 by definition. II is signed overflow, which is undefined behaviour, so no answer that includes it can be right.

More C Programming questions

Exams that ask this topic