1

enter image description here

The HackerEarth facebook page uploads MCQs like these everyday! So, I suppose that I can share this image here. It seems to me like its a compilation error! Because of the fact that there is a statement the post-increments the char array a in the for loop! But last 2 statements::

&lt;p<<k
}

Are they valid in any way? < & > are converted to &gt; &lt; etc This link says that < gets converted to &lt;! Or is it also a compiler error?

Was just curious because I couldn't trust myself that a compilation error as an extra closing bracket and a &lt;p<<k; statement could be there in a question!

Community
  • 1
  • 1
normal
  • 69
  • 8

3 Answers3

3

The last two lines are obviously not supposed to be there. This question is about the differences between arrays and pointers. You already found the answer: a is an array, not a pointer, and can therefore not be post-incremented.

2

The

&lt;p<<k
}

is probably there by accident. It's gibberish. Leaving it out, you should get an error, because a is not a pointer. You can't increment an array.

0
 &lt;p<<k 

The above code might have occurred due to some improper closing of tags/fields in their HTML code.The following has no relation with the above c program.This program makes us understand that arrays can be accessed as pointers.

Varun R R
  • 1
  • 1
  • 1