I wrote the code below expecting to get 123456789 when running. However instead I get 124457789 and I can for the life of me figure out why. Why won't my code do what I think it is supposed to do?
If I change the numbers the third and sixth number will still be the same as the fourth and seventh numbers.
#include<iostream>
#include<string>
#include<cmath>
using namespace std;
int main(){
int matrix[2][2];
matrix[0][0]=1;
matrix[0][1]=2;
matrix[0][2]=3;
matrix[1][0]=4;
matrix[1][1]=5;
matrix[1][2]=6;
matrix[2][0]=7;
matrix[2][1]=8;
matrix[2][2]=9;
cout<<matrix[0][0];
cout<<matrix[0][1];
cout<<matrix[0][2];
cout<<matrix[1][0];
cout<<matrix[1][1];
cout<<matrix[1][2];
cout<<matrix[2][0];
cout<<matrix[2][1];
cout<<matrix[2][2];
}