Header Ad

C Program to display a matrix

In this tutorial, we are going to write a C Program to display a matrix in C Programming with practical program code and step-by-step full complete explanation.

C Program to display a matrix


C Program to display a matrix.

 
#include<stdio.h>
#include<conio.h>

void main()
{
	int a[3][2],b[3][2],i,j;

	clrscr();

	printf("Enter value for a matrix: ");

	for(i=0;i<3;i++)
	{
		for(j=0;j<2;j++)
		{
			scanf("%d",&a[i][j]);
		}
	}
	printf("Enter value for b matrix: ");
	for(i=0;i<3;i++){
		for(j=0;j<2;j++)
		{
			scanf("%d",&b[i][j]);
		}
	}
	printf("\na matrix is\n\n");
	for(i=0;i<3;i++)
	{
		for(j=0;j<2;j++)
		{
			printf(" %d",a[i][j]);
		}
		printf("\n");
	}
	printf("\nb matrix is \n\n");
	for(i=0;i<3;i++)
	{
		for(j=0;j<2;j++)
		{
			printf(" %d",b[i][j]);
		}
		printf("\n");
	}
	getch();
}


Output

 
Enter value for a matrix: 7
8
9
4
5
6
Enter value for b matrix: 3
2
1
4
5
6

a matrix is
7 8
9 4
5 6

b matrix is

3 2
1 4
5 6


Post a Comment

0 Comments