Write a function REVCOL (int P[] [5], int N, int M) in C++ to display the content of a two-dimensional array, with each column content in reverse order.
Note: Array may contain any number of rows.
For example, if the content of the array is as follows:
15 | 12 | 56 | 45 | 51 |
13 | 91 | 92 | 87 | 63 |
11 | 23 | 61 | 46 | 81 |
The function should display output as:
11 | 23 | 61 | 46 | 81 |
13 | 91 | 92 | 87 | 63 |
15 | 12 | 56 | 45 | 51 |
void REVCOL(int P[][5],int N,int M)
{
for(int I=0;I<N/2;I++)
{
for(int J=0;J<M;J++)
{
int T = P[I][J];
P[I][J] = P[NI1][J];
P[NI1][J] = T;
}
}
for(I=0;I<N;I++)
{
for(int J=0;J<M;J++)
cout<<P[I][J];
cout<<endl;
}
}â