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

What is the output of the following code?
main() {
  static float a[] = {13.24, 1.5, 4.5, 5.4, 3.5};
  float *j, *k;
  j = a;
  k = a + 4;
  j = j * 2;
  k = k / 2;
  printf("%f %f", *j, *k);
}

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

Show answer & explanation

Correct answer: D. Illegal use of pointer in main function

Explanation

Multiplication and division are not allowed on pointers in C, so j * 2 and k / 2 are compile-time errors (illegal use of pointer).

More Programming Languages and Computer Graphics questions