PRINT THE BOUNDARY VALUES OF AN ARRAY
Consider the following I/O samples.
SAMPLE INPUT : 3
4 7 9
3 6 2
0 4 1
#include <stdio.h>
int main()
The given source code in C program is short and simple to understand. The source code is well tested in DEV-C++ and is completely error free. If you have any feedback about this article and want to improve this, please comment in the comment section.
3 6 2
0 4 1
SAMPLE OUTPUT: Upper Boundary : 4 7
Lower Boundary : 0 1
Left Boundary : 4 0
Right Boundary : 9 1
C PROGRAM:
#include <stdio.h>
int main()
{
int n,m,i,j,arr[100][100];
scanf("%d %d",&n,&m);
for(i=0;i<n;i++)
{
for(j=0;j<m;j++)
{
scanf("%d",&arr[i][j]);
}
}
printf("\n");
printf("Upper Boundary : %d %d\n",arr[0][0],arr[0][m-1]);
printf("Lower Boundary : %d %d\n",arr[n-1][0],arr[n-1][m-1]);
printf("Left Boundary : %d %d\n",arr[0][0],arr[n-1][0]);
printf("Right Boundary : %d %d\n",arr[0][m-1],arr[n-1][m-1]);
return 0;
}OUTPUT:
The given source code in C program is short and simple to understand. The source code is well tested in DEV-C++ and is completely error free. If you have any feedback about this article and want to improve this, please comment in the comment section.
Comments
Post a Comment