Scanning a 2D Array
An array is a contiguous block of memory.In a 2D array there are many rows.The total number of elements in the array is row x column. We use 2 for loops to access elements of the array to scan the elements.
/*
http://www.ProbCOMP.com
An array is a contiguous block of memory.In a 2D array there are many rows.The total number of elements in the array is row x column
We use 2 for loops to access elements of the array to scan the elements.
*/
#include<stdio.h>
#define ROW 3
#define COL 2
void scanning(int arr[ROW][COL])
{
printf("\nenter an array of %dx%d\n",ROW,COL);
for(int i=0;i<ROW;i++)
{
for(int j=0;j<COL;j++)
{
scanf("%d",&arr[i][j]);
}
}
}
void main()
{
int arr[ROW][COL];
scanning(arr);
}
Download Program


