#include <stdio.h>
int main()
{
int array[100][100],array1[100][100];
int i,j,c,r;
printf("Please Enter the row number: ");
scanf("%d",&r);
printf("Please Enter the column number: ");
scanf("%d",&c);
printf("Please enter a %d X %d array :",r,c);
for(i=0; i<r; i++)
{
for(j=0; j<c; j++)
{
scanf("%d",&array[i][j]);
}
}
for(i=0; i<r; i++)
{
for(j=c-1,k=0; j>=0; j--,k++)
{
array1[i][k]=array[i][j]; ///saving and swapping the column
}
}
printf("Your array is: ");
for(i=0; i<r; i++)
{
for(j=0; j<c; j++)
{
printf("%d ",array1[i][j]);
}
printf("");
}
return 0;
}
Output
Please Enter The Row Number: 3
Please Enter The Column Number: 3
Please Enter 3 x 3 Element Of the array:
1 2 3
4 5 6
7 8 9
Your array is:
3 2 1
6 5 4
9 8 7
Add your comment