Ken H

Ken H

  • NA
  • 646
  • 355.1k

The "for" cyclic of question

Aug 6 2012 10:28 AM

hi friends,
  Why output is 10 rather not 9.
Code:

#include<iostream>
using namespace std;

void main()
{
  const size_t array_size=10;
  int ia[array_size];

  for (size_t  ix=0;ix!=array_size;++ix)
  ia[ix]=ix;
  cout<<ia[ix]<<endl
;
}

/*
 my logic is:when + + X is equal to 10, you no longer perform the body of the loop statement
 right result cout<<ia[ix] output is 9,why is output is 10.
*/

thanks.

Answers (5)