All mock tests are FREE till 31 December — register to save your progress

What will be the output of the following code?
#include <stdio.h>
int main() {
  int a, b, c;
  a = 0x10; b = 010;
  c = a + b;
  printf("%d", c);
  return 0;
}

Pick an option to check yourself, or open the answer below.

Show answer & explanation

Correct answer: B. 24

Explanation

0x10 is hexadecimal 16 and 010 is octal 8, so c = 24.

More Programming Languages and Computer Graphics questions