Is this code compiling

#include <iostream>
usingnamespace std;
//Define the Matrix3X3 type.
typedefstruct
{
float index[3][3];
} Matrix3X3;
//Function prototypes (functions are defined below main())
void printMatrix( Matrix3X3 a );
Matrix3X3 inputMatrix();
Matrix3X3 addMatrices( Matrix3X3 a, Matrix3X3 b );
Matrix3X3 subtractMatrices( Matrix3X3 a, Matrix3X3 b );
Matrix3X3 scalarMultiply( Matrix3X3 a, float scale );
 
//main() function
 
 
void main()
{
cout << "Please enter matrix A:" << endl;
Matrix3X3 A = inputMatrix();
cout << "Matrix A:" << endl;
printMatrix( A );
cout << "Please enter matrix B:" << endl;
Matrix3X3 B = inputMatrix () ;
cout << "Matrix B:" <<endl;
printMatrix ( B );
printMatrix(scalarMultiply(A, 3.1415)); 
} 
 
Matrix3X3 scalarMultiply( Matrix3X3 a, float scale ) 
{ 
Matrix3X3 result; 
for(int i=0;i<3; i++) 
for(int j=0;j<3; j++) 
result.index[j][i] = scale * a.index[j][i]; 
return result;
}
Matrix3X3 subtractMatrices( Matrix3X3 a, Matrix3X3 b ) 
{ 
Matrix3X3 result; 
for(int i=0;i<3; i++) 
for(int j=0;j<3; j++) 
result.index[j][i] =a.index[j][i] - b.index[j][i]; 
return result;
} 
 
void printMatrix( Matrix3X3 a )
{
//loop through rows
for( int i=0; i < 3; ++i )
{
//loop through column at each row
for( int j=0; j < 3; ++j )
{
//i is the row
//j is the column
float temp = a.index[i][j];
cout << temp << " ";
}
//go to the next line after each row
cout << endl;
}
}
Matrix3X3 inputMatrix()
{
Matrix3X3 temp;
//loop through rows
for( int i=0; i < 3; ++i )
{
//loop through column at each row
for( int j=0; j < 3; ++j )
{
//i is the row
//j is the column
cout << "Enter row " << i << " column " << j << ":" << endl;
cin >> temp.index[i][j];
}
}
 
return temp;
}
Member Avatar for iamthwee

>is this code compiling?

Surely you could answer this yourself.

don't think so:

usingnamespace std;

Niek

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.