I am to write a program which will prompt the user for a size (NxN) matrix then
1. call a function (generate) that generates the values of the matrix using the formula:
X ij = 1.0/(I + J)
2. call a function (transpose) that finds the transpose to the matrix; call the new matrix XT. A transpose of a matrix is all rows become columns and columns become rows.
3. call a function (multiply) that multiplies matrices X and XT; call the resulting matrix XXT.
Your program should label all output and calls a function which prints a matrix.
I have the following:
#include <iostream>
#include <iomanip.h>
const int size = 100;
void generate (float x[], int n, float&xij)
{
for (int i=0; i<n; i++)
{
for (int j=0; j<n; j++)
cout.width(6);
cout.precision(3);
cout<<x[j]<<"\t";
cout<<endl;
xij = 1.0/(i+j);
}
}
void transpose(int x[], int xt[])
void multiply (int xxt)
{
int x, xt;
xxt = x * xt;
}
main ()
{
int i,j,xt,xxt,x;
cout<<"Enter number of row(s) for the matrix:"<<endl;
cin>>n1>>endl;
cout<<"Enter number of column(s) for the matrix:"<<endl;
cin>>n2>>endl;
void generate (array);
for (i=0; i<n; i++)
{
for (j=0; j<n; j++)
cout<<setw(6)precision(3)x[j]<<"\t"
void transpose (x[][], xt[][]);
void multiply (xxt);
}
I keep getting the following errors:
matrix.cpp: In function `void generate(float (*)[100], int, float &)':
matrix.cpp:11: name lookup of `j' changed for new ANSI `for' scoping
matrix.cpp:8: using obsolete binding at `j'
matrix.cpp: In function `void transpose(int (*)[100], int (*)[100])':
matrix.cpp:17: parse error before `void'
matrix.cpp: In function `void multiply(int)':
matrix.cpp:18: confused by earlier errors, bailing out