#include<stdio.h>
void read(int a[50][50],int r,int c);
void display(int a[50][50],int r,int c);
int main()
{
int a[50][50],r,c;
printf("Enter the row size of the matrix\n");
scanf("%d",&r);
printf("Enter the column size of the matrix\n");
scanf("%d",&c);
printf("Enter the matrix elements\n");
read(a,r,c);
printf("The matrix is:\n");
display(a,r,c);
}
void read(int a[50][50],int r,int c)
{
int i,j;
for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
{
scanf("%d",&a[i][j]);
}
}
}
void display(int a[50][50],int r,int c)
{
int i,j;
for(i=0;i<r;i++)
{
printf("\n");
for(j=0;j<c;j++)
{
printf("%d\t",a[i][j]);
}
}
printf("\n");
}
Output:
void read(int a[50][50],int r,int c);
void display(int a[50][50],int r,int c);
int main()
{
int a[50][50],r,c;
printf("Enter the row size of the matrix\n");
scanf("%d",&r);
printf("Enter the column size of the matrix\n");
scanf("%d",&c);
printf("Enter the matrix elements\n");
read(a,r,c);
printf("The matrix is:\n");
display(a,r,c);
}
void read(int a[50][50],int r,int c)
{
int i,j;
for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
{
scanf("%d",&a[i][j]);
}
}
}
void display(int a[50][50],int r,int c)
{
int i,j;
for(i=0;i<r;i++)
{
printf("\n");
for(j=0;j<c;j++)
{
printf("%d\t",a[i][j]);
}
}
printf("\n");
}
Output:
Comments
Post a Comment