That'll set the loop to only print the 2nd column of each row via [i][1].
Also a tip is you can (and should) set a const, or constexpr (c++11 or newer) type to rows and columns and reuse that expression for your array sizes and loop iterations.
thanks.
yes, that's what i want and then get the odd terms NOT ODD NUMBER but odd terms only in the second column ( e.x 2, 8, 15). how would i do that?
it didn't work. it just printing column 2.
i started doing this:
cout<< array[0][1]<<endl;//print the column
cout<< array[0][7]<<endl;//print the column
cout<< array[0][13]<<endl;//print the column
cout<< array[0][19]<<endl;//print the column
cout<< array[0][25]<<endl;//print the column
cout<< array[0][31]<<endl;//print the column
cout<< array[0][36]<<endl;//print the column
it printed out but how can i sum it all up?
for (int i = 0; i < M; i++)
{
for (int j = 0; j < N; j++)
{
file >> array[i][j];
if (i % 2 == 0)
even += array[i][1];
else
odd += array[i][1];
}
} cout << " Even index positions sum " << even<<endl;
cout << " n Odd index positions sum " << odd;