Site icon DataFlair

C Program to Read and Display Matrix

Program 1

// Program for read and write matrix
#include<stdio.h>
#include<conio.h>
int main()
{
    system("cls");
    int a[50][50],m,n,r,c;
    printf("\nEnter the value of row and column");
    scanf("%d %d",&m,&n);

    printf("\n Enter elements in matrix");
    for(r=0;r<m;r++)
    {
        for(c=0;c<n;c++)
        scanf("%d",&a[r][c]);
    }
    printf("\nElements of matrix\n");
    for(r=0;r<m;r++)
    {
        for(c=0;c<n;c++)
       { 
         printf("%4d",a[r][c]);
         
       }
       printf("\n");
    }
    
 
    return 0;
}

 

 

Exit mobile version