C Program to Input and Print a 2-D Array (Matrix)

 #include<stdio.h>

void main()


{

    int a[10][10],rows,cols,r,c;


    printf("\nEnter no. of rows & cols: ");


    scanf("%d%d",&rows,&cols);


    printf("\nEnter matric of %d x %d: ",rows,cols);


    for(r=0;r<rows;r++)


        for(c=0;c<cols;c++)


            scanf("%d",&a[r][c]);


    printf("\n Matrix is : ");


    for(r=0;r<rows;r++)

    {

        printf("\n");

        for(c=0;c<cols;c++)


            printf("%d ",a[r][c]);

    }

}

Comments

Popular posts from this blog

Single Program Using All Automatic String Functions

C program for subtraction of two matrices (2D Arrays)

C program for Multiplication of Two matrices