double x[12] will allocate memory for 12 doubles regardless if those actually got values or not...so sizeof(x) is a constant here...
You have two options:
1. introduce a global index (next to x) to incrase after every input...
double x[12]
int i = 0;
void AddPayment(double Amount)
{
x[i] = Amount;
i++;
}
(You have to take care of i >= 12)
2. Initialize the array with some negative value and check in each round where is the first and update...