Hi guys I am working on this program
Array Manipulation - Transpose of a Square Matrix: This program reads a matrix (two dimensional array), displays its contents, transposes it and then displays the transposed matrix.
and here's the code
Code:
#include <iostream.h>

const int arraySize = 3;

void readMatrix(int arr[][arraySize]);
void displayMatrix(int a[][arraySize]);
void transposeMatrix(int a[][arraySize]);

void main(void)
{

int a[arraySize][arraySize]; 

readMatrix(a); //Read the matric element int the array

cout<<"\n\n"<<"The original matrix is:"<<'\n'; //Display the matrix

displayMatrix(a);

transposeMatrix(a); //transpose the matrix

cout<<"\n\n"<<"The transposed matrix is:" << '\n'; //Display the transposed matrix
displayMatrix(a);
}

void readMatrix(int arr[][arraySize])
{
     int row, col;
     
     for(row = 0; row<arraySize;row++)
     {
             for(col=0; col<arraySize; col++)
             {
                        cout<<"\n"<<"Enter"<<row<<","<<col<<"element";
                        cin>>arr[row][col];
                        }
                        cout<<'\n';
                        }
                        }
             void displayMatrix(int a[][arraySize])
             {
                  int row,col;
                  for (row=0; row<arraySize;row++)
                  {
                      for(col=0; col<arraySize; col++)
                      {
                                 cout<<a[row][col]<<'\t';
                                 }
                                 cout<<'\n';
                                 }
                                 }
                       void trnasposeMatrix(int a[][arraySize])
                       {
                            int row,col;
                            int temp;
                            for(row=0; row < arraySize; row++)
                            {
                            for(col=row; col<arraySize;col++)
                            {
                            temp=a[row][col]; //save the original value in the temp variable
                            a[row][col]=a[col][row];
                            a[col][row]=temp; //take out the original value
                            }
                            }
                            }
When I compile the program it says 'mail' must return 'int' I think everything is right please help me on this....