It's because &a has type int(*)[6] and hence &a + 1 != &a[0] + 1 which is what you meant, given your expected output.
If you print the addresses &a and &a[0], they will be the same, however incrementing &a is not the same as incrementing &a[0] because sizeof(int) != sizeof(int *), although that's not always true, your code should not assume it is, or depend on that.
Also, it appears that your are using the cast because your compiler was complaining about the fact that &a is of an incompatible pointer type, you should not need the cast if the pointers are of compatible types so
#include <stdio.h>
int main()
{
int a[] = {1, 2, 3, 4, 5, 6};
int *ptr = &a[0] + 1;
printf("%d\n", *(ptr-1));
return 0;
}
should compile just find, and the output will be 1 as you expected.
output should be 1 but it is not 1...so what is it?&aisint (*)[6]. it meant pointer toint[6]. so&a + 1point to next(a[6]) the last element(6:a[5]). then cast toint *then-1so point to last element6.