Im supposed to put values into a 2D array. The initialization looks like this: int arr[10][4]
So the output supposedly looks like this. Values are supposed to be inserted by user:
Test1 Test2 Test3 Test4 0 0 0 0 0 0 0 0 0 0 0 0 -1
Thing is, when -1 is entered, the previous values are supposed to be saved and the loop is supposed to end, even if 10 columns arent reached. I have no clue as to how to do it. Ive tried putting break; statement in my code. I dont think im doing it right. Little help?
Here's my code:
void InitializeArray(int arr[10][4])
{
for(int i=0; i<10; i++)
{
for(int j=0; j<4; j++)
{
cout<<"Input value ["<<i<<"]["<<j<<"] : ";
cin>>arr[i][j];
}
}
}
Also, im supposed to find the average of the tests. Both horizontally and vertically. So that the output looks something like this:
Test1 Test2 Test3 Test4 Average Minimum
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
Average 0 0 0 0
Minimum 0 0 0 0 0
So.. im guessing somehow, the number of columns need to be stored in an int? But how do i do that?

New Topic/Question
Reply




MultiQuote










|