ProgrammingHardAccenture · Capgemini · C

What is the output of this C program (assume a typical 64-bit platform: int 32 bits, long and pointers 64 bits, double 8 bytes, structs aligned to their widest member with no packing pragma)? #include <stdio.h> int main(void) { int x = 3; switch (x) { case 1: printf("one"); break; case 2: printf("two"); break; case 3: printf("three"); case 4: printf("four"); break; default: printf("other"); } return 0; }

  1. A. four
  2. B. threefour
  3. C. three
  4. D. other

Correct answer: B. threefour

Without a break after case 3, execution falls through into case 4 as well, printing both "three" and "four".

More C Programming questions

Exams that ask this topic