Monday, 14 July 2014

PROGRAM FOR 2D- ARRAY


PROGRAM TO READ AND PRINT A 2D ARRAY


#include<stdio.h>
#include<conio.h>

void main()
{
int n,m,i,j,a[20][20];
clrscr ( );
printf("enter number of rows\n");
scanf("%d",&n);
printf("enter number of columns\n");
scanf("%d",&m);
printf("enter elements in the array\n");

for(i=0;i<n;i++)
{
  for(j=0;j<m;j++)
{
scanf("%d",&a[i][j]);
}
 }
printf("the elements are\n");

for(i=0;i<n;i++)
{
for(j=0;j<m;j++)
{
printf("%d",a[i][j]);
}
}
getch( );
}

No comments:

Post a Comment