Help me correct this code pls

I made this code
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include <iostream>

#include <iomanip>
using namespace std;

const int ro=5;
const int col=5;

void multi(int mb[ro][col])
{
for (int i = 1; i < ro; i++) {
mb[0][i] = i;
}

for (int i = 1; i < ro; i++){
mb[i][0] = i;

for (int j = 1; j < col; j++)
mb[i][j] = i * j;
}
}

int main()
{
	int mb[ro][col] ={};

multi(mb);


for (int i = 0; i < ro; i++) {

	
for (int j = 0; j < col; j++) {

cout << "   " << setw(4) << mb[i][j];

}
cout << endl;
}
system("pause");
return 0;

} 

it outputs a 5x5 multiplication table...the thing is the professor wants us to use global variables for the array as well
so i think the code would look something like this
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include <iostream>
#include <iomanip>
using namespace std;

const int ro=5;
const int col=5;
int mb[ro][col];

void multi()
{
for (int i = 0; i < 5; i++) {
	
for (int j = 0; j < 5; j++){

	mb[ro][col]= i * j;


}
}
}


int main()
{


multi();


for (int i = 0; i < 5; i++) {

	
for (int j = 0; j < 5; j++) {

cout << "   " << setw(4) << mb[ro][col];

}
cout << endl;
}
system("pause");
return 0;

} 

the thing is i only get 16's :D I know I'm missing something but i can't see it .thanks :)
Last edited on
closed account (SECMoG1T)
mb[ro][col];//line 35 change ro and col to i and j
i changed ro and col as suggested but i only get 0's D:
closed account (SECMoG1T)
Ooh sorry i forgot change line 15 too to the same
w00t m8 thanks for the help you made a man happy today :D
Topic archived. No new replies allowed.