Accepting and displaying Element using 2d array in c program

Accepting and displaying Element using 2d array in c program

  1. #include<stdio.h>
  2. int main()
  3. {
  4.   int a[2][2];
  5.     int i, j; 
  6.       //Logic to read matrix
  7.         for ( i = 0; i < 2; i++ ) //related to row
  8.           { 
  9.              for ( j = 0; j < 2; j++ ) //related to column
  10.                 { 
  11.                      scanf("%d", &a[i][j]); 
  12.                         }
  13.                           }
  14.                              for(i = 0; i < 2; i++) 
  15.                                 {
  16.                                        for(j = 0; j < 2; j++)
  17.                                               {
  18.            printf("Array Element %d\t",a[i][j]);
  19.                   } 
  20.                          printf("\n");
  21.                             }
  22.   return 0; 
  23.   } 

Output


//Entered array Element
1 2
3 4
//Displayed array Element
Array Element 1 Array Element 2
Array Element 3 Array Element 4 

choose next program from this list

Comments