Function won't print what is wrong with it?

I'm trying to multiply a 2d array by itself until the specified location is no longer zero but for some reason it will not print on the console.
Why is this happening?
Does my code do what I want it to do?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
//assume I called the function correctly
  void gr2 (int graph2[][6])
{
    int result[6][6] = {0};
    int counter = 0;
    
    if (graph2[0][1] == 1){
        
        cout << "Shortest path from A to B is: " << graph2[0][1] << endl;
    }
    else {
       while (result[0][1] < 1){
            for(int r = 0; r < 7; ++r)
                for(int c = 0; c < 7; ++c)
                    for(int x = 0; x < 7; ++x)
                    {
                        result[r][c]+= graph2[r][x] * graph2[x][c];
                    }
        counter++;
    }
        cout << "Shortest path from A to B is: " << counter << endl;
    }
    
    
}
Last edited on
what are you passing into it?
I figured it out.
was an infinte loop.
prog doesn't work though.
Topic archived. No new replies allowed.