Monday, March 20, 2017

Declaration and print of 2 D Array

#include<stdio.h>
main()
{
    int row,col;
   int A[2][2]={3,4,2,6};
   printf("Matrix A :\n");
   for(row=0;row<2;row++)
   {
       for(col=0;col<2;col++)
       {
           printf("\tA[%d][%d]=%d ",row,col,A[row][col]);
       }
       printf("\n\n");
   }
   ///B mat
    int B[2][3]={3,2,6,4,7,8};
   printf("Matrix B :\n");
   for(row=0;row<2;row++)
   {
       for(col=0;col<3;col++)
       {
           printf("\t%d ",A[row][col]);
       }
       printf("\n");
   }
}

No comments:

Post a Comment