
twodimensional arrays
We had to write three two dimensional arrays A[10][10],B[10][10],C[10][10]. Cin numbers into A and B and then add them together and store them in C. using the numbers 09,now we have to tell how many numbers in A are 1, how many are 2, and so on. In B we have to show how many 1,3,5,7,9 were used. and display the output. I finally got the numbers input and added but how to I figure how many of each number was used?
Thanks for any help.
jblea

You could use a double for loop to transverse the colums and rows.
Code:
int one = 0, two = 0, three = 0; // etc.....
int data;
for( int row = 0; row < 10; row++ )
{
for( int col = 0; col < 10; col++ )
{
data = A[col][row];
switch( data )
{
case 1: // If it's a 1, then increment counter
one++;
break;
.
.
.
}
}
}
Hope this helps :) If not, IM me or post back

if you didn't like the switch, try a bunch of if's:
Code:
//....
data = A[col][row];
if (data==1)
one++;
//.....

Thanks guys I'll work on finishing it today.