My C++ Quiz

The ultimate place to learn C++!

Question #42: What value gets printed by the program?

#include <iostream>

int main() 
{ 
  int sum = 0;

  int array[3][] = {{0, 1, 2}, {3, 4, 5}, {6, 7, 8}};

  for (int i = 0; i < 3 ; ++i)
  {
    for (int j = 2; j < 3 ; j++)
    {
      sum += array[i][j];
    }
  }

  std::cout << sum << std::endl;

  return 0;
}