/******************************************************************************
Online C Compiler.
Code, Compile, Run and Debug C program online.
Write your code in this editor and press "Run" button to compile and execute it.
*******************************************************************************/
#include <stdio.h>
void shift(int p[4][5]);
int main()
{
int i, j, a[4][5];
printf("Enter the elements of the 4X5 matrix:\n");
for (i = 0; i < 4; i++)
{
for (j = 0; j < 5; j++)
{
scanf("%d", &a[i][j]);
}
}
printf("Entered Matrix:\n");
for (i = 0; i < 4; i++)
{
for (j = 0; j < 5; j++)
{
printf("%d ", a[i][j]);
}
printf("\n");
}
printf("\n");
shift(a);
printf("The new array is:\n");
for (i = 0; i < 4; i++)
{
for (j = 0; j < 5; j++)
{
printf("%d ", a[i][j]);
}
printf("\n");
}
printf("\n");
return 0;
}
void shift(int p[4][5])
{
int i;
for (i = 0; i < 4; i++)
{
int temp[2] = { **(p + i),*(*(p + i) + 1) };
*(*(p + i) + 0) = *(*(p + i) + 2);
*(*(p + i) + 1) = *(*(p + i) + 3);
*(*(p + i) + 2) = *(*(p + i) + 4);
*(*(p + i) + 3) = temp[0];
*(*(p + i) + 4) = temp[1];
}
}