Wednesday, March 24, 2021

11.1 Write a program that read and display a matrix.

#include<stdio.h> 
#include<conio.h>
void main ()
{
int i,j,r,c,a[10][10];
clrscr();
printf ("How many row: "); 
scanf ("%d", &r);
printf ("How many column: ");
scanf ("%d",&c);
for (i=0; i<r; i++)
for (j=0; j<c; j++)
scanf ("%d", &a[i][j]);
for (i=0; i<r; i++) 
{
for(j=0; j<c; j++) 
printf("%4d", a[i][j]); 
printf("\n");
}
getch ();
}

No comments:

Post a Comment