int *ptr ;
ptr is uninitalised which means it contains some garbage value.
*ptr = *(arr + 2);
Dereferencing a garbage value will lead to undefined behaviour, usually program crashing. You're trying to access memory that you don't have permission to, resulting in a segmentation fault.