5
Answers

The "for" cyclic of question

Ken H

Ken H

12y
2.6k
1

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)