1. Insertion sort algorithm help

I'm supposed to write a program that will use insertion sort to sort 12 numbers in an array. Right now my program will sort the numbers but always has 12 at the end even if it is not inputted and negative numbers are not working. can anybody help me out?
Here's what i have so far.
Code:
```#include <stdio.h>

int main(void)
{
int a[12];
int z = 0, b = 1, j, temp;

while( b <= 12){
printf("Enter number %d: ", b);
scanf("%d", &a[z]);
for(z = 1; z <b; z++)
{
temp = a[z];
j = z - 1;
while(temp<a[j] && j >=0)
{
a[j + 1] = a[j];
j = j - 1;
}
a[j +1] = temp;
}

z++;
b++;
}
for(z = 0; z <=b; z++){
printf("%d\t", a[z]);
z++;}

return 0;

}```

Thanks!

2. If you have an array of 12 elements, the first one is a[0] and the last one is a[11]. You seem to be going from 1 to 12 in places and from 1 to 11 in other places. a[12] does not exist; if you are referring to it, you are referring to memory that doesn't belong to you and anything could happen.

3. Oh yea that fixed one of my problems but I forgot that its not printing out all the elements of the array only 6 of them. You know whats causing that problem?

4. Never mind I didn't notice i had z incrementing twice i got it working thanks for the help!