C Program to Read and Display Matrix

Get Certified in C Programming and Take Your Skills to the Next Level

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;
}

 

 

Your opinion matters
Please write your valuable feedback about DataFlair on Google

courses

DataFlair Team

DataFlair Team provides high-impact content on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. We make complex concepts easy to grasp, helping learners of all levels succeed in their tech careers.

Leave a Reply

Your email address will not be published. Required fields are marked *