Transpose Matrix array manipulation

Hi guys I am working on this software
Array Manipulation - Transpose of a Square Matrix: This program reads a matrix (twol
dimensional array), displays its contents, transposes it and then displays the transposed matrix.
and here's the code
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

#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....
Topic archived. No new replies allowed.