Hi
I'am new to programming and i need help concerning 2D arrays. If i read in data values from a file and stored these data into a 2D array. How can i manipulate the datas stored within this array?? Say...
My Array is;
float num[3][2];
and the file data is;
intergers1 integers 2
1 2
3 4
5 6
Now the manipulation is, i want to sum up all values under heading (integers2) and print out the sum.
To add up the numbers you want, just think of how the indices change as you move through the array. You know that the first dimension index has to increase by 1 each time, and that the second dimension index is always 1 since you always want the 2nd value. So we can create a single loop to sum these numbers:
[code=c++]
sum = 0;
for( int i = 0; i < 3; i++ ) {
sum += num[i][1];
}
[/code]