Help needed!!!!

int beta[3][3];
the output I was told would be stored in the statements is
000
012
024
not getting this output.
my code is below what am I doing wrong
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <iostream>

using namespace std;


int main()
{
	int beta [3][3];
	int i,j;
	
	
	for (i = 0; i < 3; i++)
	{
	for (j = 0; j < 3; j++)
	{
		beta [i] [j] = i * j;


	}
	}
	cout << beta [3][3] << endl;

	return 0;
}




For (I = 0; I < 3; i++)
For (j = 0; j < 3; j++)
Beta [i] [j] = I * j;
cout << beta [3][3] << endl;


This does not output the entire array like you seem to think it does. It accesses element [3][3] and outputs that (note that [3][3] is out of bounds and therefore this accesses unallocated memory which may crash your program or may just print garbage).

If you want to print the whole array you'll have to do it in a loop, similar to how you're doing the multiplication in the loop.
Your arrays have indicies from 0 to 2, yet you are accessing index 3, which does not exist, on line 21.
ok thanks
Topic archived. No new replies allowed.