Monday, March 20, 2017

Input a matrix and output(2D Array practice)

#include<stdio.h>
main()
{
    int row,col,i,j;
     printf("Row number = ");
     scanf("%d",&row);///row = 3
     printf("Col number = ");
     scanf("%d",&col);///col = 2
     int A[row][col];

     printf("Enter the matrix entity  \n");
     for(i=0;i<row;i++)
     {
         for(j=0;j<col;j++)
         {
             scanf("%d",&A[i][j]);
         }
     }

     printf("Matrix A=  \n");
     for(i=0;i<row;i++)
     {
         for(j=0;j<col;j++)
         {
             printf("\t%d  ",A[i][j]);
         }
         printf("\n");
     }

}

No comments:

Post a Comment