ProgrammingHardHCL · Tech Mahindra · C placement

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 total = 0; for (int i = 1; i <= 5; i++) { if (i % 2 == 0) continue; total += i; } printf("%d", total); return 0; }

  1. A. 15
  2. B. 9
  3. C. 12
  4. D. 6

Correct answer: B. 9

continue skips the even i values (2, 4); only 1, 3, 5 are added: 1+3+5=9.

More C Programming questions

Exams that ask this topic