Error with brace and subscript which requires array or pointer type. Code written, needs slight tweaking to debug?

Hi,

So I have a code written to multiply 2 inputted matrices together and display the answer. However there are a few errors I can't seem to rectify:

Line(53): error C2109: subscript requires array or pointer type
Line(53): error C2109: subscript requires array or pointer type
Line(55): error C2109: subscript requires array or pointer type
Line(59): error C2143: syntax error : missing ';' before 'type'
Line(67): error C2109: subscript requires array or pointer type
Line(73): fatal error C1075: end of file found before the left brace '{'

I would really love this to debug so any help would be appreciated? Just any tweaking to make it a viable program.#


EDIT: just rectified error C2109, now I have the fatal error C1075 left and C2143
Did this by changing firstbysecond to firstbysecond[5][5], etc...

code written as follows:

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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include <stdio.h>

void matrix_multiply(int firstarray[5][5], int secondarray[5][5], int firstbysecond[5][5], int i, int j, int k, int sum); 
void display_matrix(int firstbysecond[5][5], int i, int j);

void main()
{
	int firstarray[5][5];
	int secondarray[5][5];
	int firstbysecond[5][5];
	int i;
	int j;
	int k;
	int sum;

	for (i=0; i<5; i++)
	{
		for (j=0; j<5; j++)
		{
			printf("Enter an element for the first array:\n");
			scanf("%d", &(firstarray[i][j]));
		}
	}

	for (i=0; i<5; i++)
	{
		for (j=0; j<5; j++)
		{
			printf("Enter an element for the second array:\n");
			scanf("%d", &(secondarray[i][j]));
		}
	}

	matrix_multiply(firstarray, secondarray, firstbysecond, i, j, k, sum);

	display_matrix(firstbysecond);

	system("pause");

	return;
}

void matrix_multiply(int firstarray, int secondarray,int firstbysecond, int i,int j,int k,int sum)
{

	for (i=0; i<5; i++)
	{
		for (j=0; j<5; j++)
		{
			sum=0;
			for (k=0; k<5; k++)
			{
				sum += firstarray[i][k] * secondarray[k][j];
			}
			firstbysecond[i][j]=sum;
		}
	}

	void display_matrix(int firstbysecond, int i, int j);
	{
		printf("The first matrix multiplied by the second matrix is the matrix:\n");

		for (i=0; i<5; i++)
		{
			for (j=0; j<5; j++)
			{
				printf("\t %d",firstbysecond[i][j]);
			}
			printf("\n");
		}

	}
Last edited on
On line 43: All parameters must match the prototype on line 3

There need to be a closing brace after line 72
Last edited on
Topic archived. No new replies allowed.