user19498: Here's a simple sketch. I have an array data and a variable idx. 
I'm assigning a value to each of the array element, and then sending them to my serial monitor.
volatile uint16_t data[5];
volatile uint16_t idx = 5;


void setup() {
  Serial.begin(9600);

  while (!Serial) { }
  Serial.println("\nHello!");

  data[0] = 1010;
  data[1] = 1011;
  data[2] = 1012;
  data[3] = 1013;
  data[4] = 1014;

  for(int i = 0; i< idx; ++i)
  {
    Serial.print(data[idx]);
    Serial.write(",");
  }

  while(1){  }
}

void loop() {}

When I look into my serial monitor, I get this:
Hello!
0,0,0,0,0,

Why is this happening? Did I overlook something fundamental? I'd appreciate if you could offer your thoughts on this. 
I'm testing this code on Arduino Mega2560.

user4143: You got confused here:
Serial.print(data[idx]);

You're printing array slice 5 (the sixth entry in a 5 entry array) 5 times.
You probably meant to write:
Serial.print(data[i]);

To improve clarity you may want to #define it instead:
#define DATA_SIZE 5
uint16_t data[DATA_SIZE];

... 

for (int i = 0; i < DATA_SIZE; i++) {
    ....
}

Or you can do it the other way round (get the size from the array):
uint16_t data[5];
#define DATA_SIZE (sizeof(data) / sizeof(data[0]))


19498: <p>Here's a simple sketch. I have an array <code>data</code> and a variable <code>idx</code>. 
I'm assigning a value to each of the array element, and then sending them to my serial monitor.</p>

<pre><code>volatile uint16_t data[5];
volatile uint16_t idx = 5;


void setup() {
  Serial.begin(9600);

  while (!Serial) { }
  Serial.println("\nHello!");

  data[0] = 1010;
  data[1] = 1011;
  data[2] = 1012;
  data[3] = 1013;
  data[4] = 1014;

  for(int i = 0; i&lt; idx; ++i)
  {
    Serial.print(data[idx]);
    Serial.write(",");
  }

  while(1){  }
}

void loop() {}
</code></pre>

<p>When I look into my serial monitor, I get this:</p>

<pre><code>Hello!
0,0,0,0,0,
</code></pre>

<p>Why is this happening? Did I overlook something fundamental? I'd appreciate if you could offer your thoughts on this. </p>

<p>I'm testing this code on Arduino Mega2560.</p>
 4143: <p>You got confused here:</p>

<pre><code>Serial.print(data[idx]);
</code></pre>

<p>You're printing array slice 5 (the sixth entry in a 5 entry array) 5 times.</p>

<p>You probably meant to write:</p>

<pre><code>Serial.print(data[i]);
</code></pre>

<p>To improve clarity you may want to <code>#define</code> it instead:</p>

<pre><code>#define DATA_SIZE 5
uint16_t data[DATA_SIZE];

... 

for (int i = 0; i &lt; DATA_SIZE; i++) {
    ....
}
</code></pre>

<p>Or you can do it the other way round (get the size from the array):</p>

<pre><code>uint16_t data[5];
#define DATA_SIZE (sizeof(data) / sizeof(data[0]))
</code></pre>
