Reading and displaying the elements of two dimensional array
#include< stdio.h >
void main(){
int array1[10][10], i, j, n, m;
void main(){
int array1[10][10], i, j, n, m;
// reading the size of array
printf(" enter the size of array <10");
scanf("%d%d", &n, &m) ;
// reading the elements of array
printf(" enter elements of first matrix ");
for( i=0; i<n ;i++){
for(j=0; j<m; j++){
scanf( "%d", &array1[i][j]);
}
}
// Printing the elements of array
printf(" entered elements of array are \n");
for( i=0; i<n ;i++){
for(j=0; j<m; j++){
printf( "%d ", array1[i][j]);
}
scanf("%d%d", &n, &m) ;
// reading the elements of array
printf(" enter elements of first matrix ");
for( i=0; i<n ;i++){
for(j=0; j<m; j++){
scanf( "%d", &array1[i][j]);
}
}
// Printing the elements of array
printf(" entered elements of array are \n");
for( i=0; i<n ;i++){
for(j=0; j<m; j++){
printf( "%d ", array1[i][j]);
}
printf(" \n ");
}
}
}
}
No comments:
Post a Comment