Help with matrix problem?

ok so i have a test tomorrow and i cannot seem to get the final part of this practice problem right.
4. Write a program to open a file for reading that has twenty (20) rows and in each row there are three (3) columns. After reading each row call a user-defined function to display each row and average of each row as follows and print the results on the monitor. Assume all the numbers are integer. If the file can’t be opened you should prompt “Invalid file” and exit. (24 points)

Row 1: 2 3 4 and Average = 3
Row 2: 7 8 0 and Average = 5
Heres my code...only the function is included i got the rest and i ask the user for the rows and columns so i passed that with pointers to the function.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
 void Raverage(float (*ptx)[100], float *row, float *col)
{
	int c = 1;
	float mean = 0;
	for (int i = 0, x = 0; i < *row; i++,x++)
	{

		 for (int j = 0; j < *col; j++)
		 {
			 mean += *(*(ptx + i) + j);  // saves the sum of each row

		 }

		 cout << "row " << c++ << " " << *(*(ptx + i) + x) << " and average = " << mean / *col << endl;
	 
		 mean = 0;
	}
 
	 




}

Topic archived. No new replies allowed.