Initially pointers p,q and c are pointing to first element of the array c[].
First pointer c is pointing to first element of array;i.e;2
So first loop will print 2,five times
22222
every iteration q is pointing to next element.So,after five iterations it points to an adress out of array.
In second loop,
p prints content at first element(2),
and then it points to next (p++),
So,23465 is printed.
Total output :
22222
23465