How to square a matrix

Write your question here.
I have the code which creates the matrix, but I am having trouble squaring the matrix I have created.
It would be easier to help if you post the code and tell us what trouble are you having.
void display (int nums[ROWS][COLS])
{
int rownum, colnum;
for ( rownum = 0; rownum < ROWS; rownum++)
{
for (colnum = 0; colnum < COLS; colnum++){
cout << setw(5) << nums [rownum][colnum];}

cout << setw(5) << nums[rownum][colnum];
cout << endl;
}
return;
}
int main ()
{
int M [ROWS][COLS];
cout << "Enter in 9 elements for a 3x3 matrix." << endl;
cin >> M[0][0] >> M[0][1] >> M[0][2] >> M[1][0] >> M[1][1] >> M[1][2] >> M[2][0] >> M[2][1] >> M[2][2];
return 0;
}
Sorry, that is my code.
First, please use code tags when posting code. See http://www.cplusplus.com/articles/jEywvCM9/

Is that really your entire code?

What does "to square a matrix" mean?
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
#include <iostream>
#include <iomanip>
#include <cmath>

using namespace std;

double x;
double y;
double x_comp;
double y_comp;
double angle;
const int ROWS = 3;
const int COLS = 3;
void display (int [ROWS][COLS]);

vectorRot()
{

}

squaredMatrix()
{

	
}

void display (int nums[ROWS][COLS])
{
int rownum, colnum;
	for ( rownum = 0; rownum < ROWS; rownum++)
{
	for (colnum = 0; colnum < COLS; colnum++){
		cout << setw(5) << nums [rownum][colnum];}
	
	cout << setw(5) << nums[rownum][colnum];
	cout << endl;
}
return;
}

matrixDisplay()
{
}

int main ()
{
	cout << "Enter a value for x." << endl;
		cin >> x;
	cout << "Enter a value for y." << endl;
		cin >> y;
	cout << "Enter a value for the angle of rotation." << endl;
		cin >> angle;
			x_comp = (x*cos(angle) + (y*sin(angle)));
			y_comp = (y*-sin(angle) + (y*cos(angle)));
	cout << "The resulting vector has a x component of " << x_comp << endl;
	cout << "The resulting vector has a y component of " << y_comp << endl;



int M [ROWS][COLS];
cout << "Enter in 9 elements for a 3x3 matrix." << endl;
cin >> M[0][0] >> M[0][1] >> M[0][2] >> M[1][0] >> M[1][1] >> M[1][2] >> M[2][0] >> M[2][1] >> M[2][2];
return 0;
}
This is my whole code. Sorry, I'm new here haha. Anyway, I have just started programming and I am having difficulties.
and squaring a matrix just means to multiply a matrix by itself.
How does one multiply two matrices? (In math.)
Topic archived. No new replies allowed.