Can't access the value of the i-th element of array

Hello everyone,
I am having a problem with accesing the value of i-th element of array in the code below:

int i=0;
int pulse_x[100];
int pulse_y[100];
int pulse_z[100];
void loop(){
    pulse_x[i]=i+1;
    pulse_y[i]=i+2;
    pulse_z[i]=i+3;
    i = i + 1;
    char str[20];
    sprintf(str, "%d,%d,%d,%d", i, pulse_x[i], pulse_y[i], pulse_z[i]);
    Serial.println(str);
    Serial.print(i);
    Serial.print(' ');
    Serial.print(pulse_x[i]);
    Serial.print(' ');
    Serial.print(pulse_y[i]);
    Serial.print(' ');
    Serial.print(pulse_z[i]);
    Serial.println(" a");
    delay(100);
    if (i==100) exit(0);
}

The value of the whole array return 0 in Serial monitor. How can I get the right value? Thank you guys.

You are incrementing i too early. Do it after printing the values otherwise it points to the next array element rather than the current one

if the size of the array is 100, what is the maximum index value?

exit(0) is a strange way to end a loop… normally you would:

int pulse_x[100];
int pulse_y[100];
int pulse_z[100];
char str[20];

void setup(){
  for (int i=0; i < 100;  i = i + 1)
  {
    pulse_x[i]=i+1;
    pulse_y[i]=i+2;
    pulse_z[i]=i+3;

    sprintf(str, "%d,%d,%d,%d", i, pulse_x[i], pulse_y[i], pulse_z[i]);
    Serial.println(str);
    Serial.print(i);
    Serial.print(' ');
    Serial.print(pulse_x[i]);
    Serial.print(' ');
    Serial.print(pulse_y[i]);
    Serial.print(' ');
    Serial.print(pulse_z[i]);
    Serial.println(" a");
    delay(100);
  }
}

void loop(){ }

UKHeliBob:
You are incrementing i too early. Do it after printing the values otherwise it points to the next array element rather than the current one

OMG I'm so stupid, thank you :o :o :o

Not stupid, just human

the "off by 1" bug is the most common