function header, prototypes, and call.

Hey, I'm using functions to add two matrices (two 2-d arrays) but I having some issues with function "add" header, call, and prototypes
Any help appreciated!



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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
 
#include<iostream>
#include<fstream>

using namespace std;

int matrix1 ();
int matrix2 ();
void add ();

int main()
{

matrix1 ();
matrix2 ();
add ( );


return 0;
}



int matrix1 ( )
{
	const int i=3;
	const int j=3;
	int a[i][j];
	
 cout<<"\n\nEnter elements for Matrix A :::\n\n";
 
    for(int x=0;i<3;x++)
    {
        for(int y=0;j<3;y++)
        {
            cin>>a[i][j];
        }
        cout<<"\n";
    }
	return (a[i][j]);
}

 

int matrix2 ()
{
	const int i=3;
	const int j=3;
	int b[i][j];
	
 cout<<"\n\nEnter elements for Matrix A :::\n\n";
 
    for(int x=0;i<3;x++)
    {
        for(int y=0;j<3;y++)
        {
            cin>>b[x][y];
        }
        cout<<"\n";
    }
	return (b[i][j]);
}






void add (int a [3][3],int b [3][3] )

{
	const int i=3;
	const int j=3;
	

	cout<<"\n\nAddition of the two Matrices  :\n\n";

    for(int x=0;i<3;x++)
    {
        for(int y=0;j<3;y++)
        {
            cout<<"\t"<<a[x][y]+ b[x][y];
        }
        cout<<"\n\n";
    }


}


your add(); function need parameters ie: 2d arrays of type int ,to work .You are not providing that in the main.
I did that
 
add (int a[i][j],int b[i][j]);


but after building it, I got this error:

 
'int' should be preceded by ')'




but I don't miss any!
Still need help please
the values has to be in the main and not in the function.Find a way to pass it to the main
also on all the value taking codes
1
2
3
4
5
6
7
8
for(int x=0;x<3;x++)
    {
        for(int y=0;y<3;y++)  // i,j are constants and does not change so there is no need of them
        {
            cout<<"\t"<<a[x][y]+ b[x][y];
        }
        cout<<"\n\n";
    }
ok I got it, thank you!
Topic archived. No new replies allowed.