C++, 2 dimensional arrays ! Please tell me how to do the (c) and (b) part of this so that I can get started. I am really new to this concept! Any help appreciated ! http://screencast.com/t/NVx3zNWGTGdb
for(i=0;i<n;i++) for(j=0;j<n;j++) AR[i]=AR[i]*AR[j] given some hints..think about it now
``` for(i=0;i<n;i++) for(j=0;j<n;j++) AR[i]=AR[i]*AR[j] //Huh? ``` Because it requires a 2d array, it will be declared it as: `int Table[10][10]` However, the nested loops is a part of the solution to this. ``` for(int i = 0; i<table_columns; i++) { for(int j = 0; j<table_rows; j++) { // do something with Table[?][?] } } ```
I already went that far, please, can you help me a bit more ? Like a silght step further
sry the site is blocked here :( can't help
There seems to be a } in the wrong place. Also, I am not sure why you are using so man variables, especially in the global scope.... i, j, o, u? I think yo could do it with just i and j. Also, this is a miltiplication table. I see some addition going on, but no multiplication. If you look at a Row i \(\times\) Column j form, it is like this: \(\begin{array}{|c|c|} \hline \, & \, & A[i][0] & A[i][1] & A[i][2] & A[i][3] \\ \hline \, & \,& 1 & 2 & 3 & 4 \\ \hline A[0][j] & 1 & 1\cdot 1 & 1\cdot 2 & 1\cdot 3 &1\cdot 4\\ \hline A[1][j] & 2 & 2\cdot 1 & 2\cdot 2 & 2\cdot 3 & 2\cdot 4 \\ \hline A[2][j] & 3 & 3\cdot 1 & 3\cdot 2 & 3\cdot 3 & 3 \cdot 4 \\ \hline A[3][j] & 4 & 4\cdot 1 & 4\cdot 2& 4\cdot 3 & 4 \cdot 4 \\ \hline \end{array}\) Note that the i and i of the A[i][j] position is one less for both i and j than what needs to be miltiplied! So A[0][0] is NOT \(0\cdot 0\) but is actually \(1\cdot 1=1\). Similarly, \(A[5][7] = (5+1)(7+1)=48\)
Join our real-time social learning platform and learn together with your friends!