The program has undefined behaviour because the memory outside the array was overwritten.
And it is the reason why in your system the program outputed only 5 elements. Variable n
was overwritten with value 5 in the following loop when the array was initialized.
//...
int arr[10];
n=15;
for(i=0;i