138. C Program to print the Inner Square of the given matrix.
How does this program work?
- In this programme you will learn about how to find the inner square of the given matrix.
- Matrix elements are stored in array variables.
Here is the code
#include <stdio.h>
void printBoundary (int a[][4], int m, int n)
{
for (int i = 1; i < m; i++)
{
for (int j =1 ; j < n-1; j++)
{
if ( i == 1)
printf("%d ",a[i][j]);
else if ( i == m/2)
printf("%d ",a[i][j] );
else
printf(" ");
}
printf("\n");
}
}
//Program to test above function
int main(void)
{
//Intialise matrix elements and rows and columns
int a[4][4] = { 1, 2, 3, 4 ,2,3,6,1,3,4,2,1,4,3,2,1} ;
printBoundary(a, 4, 4);
return 0;
}