C Program to Scan and Print Matrix

C Program to Scan and Print Matrix

Write C Program to Scan and Print Matrix

// C Program to Scan and Print Matrix

#include <stdio.h>

int main()
{
	int A[3][3], i, j;


	for(i = 0; i < 3 ; i++)
	{
		for(j = 0; j < 3; j++)
		{
			printf("Enter A[%d][%d] :--> ", i, j);
			scanf("%d", &A[i][j]);
		}
	}

	printf("\nThe matrix is :--> \n");
	for(i = 0; i < 3 ; i++)
	{
		for(j = 0; j < 3; j++)
		{
			printf("%d  ", A[i][j]);
		}
		printf("\n");
	}
	return 0;
}

Output:

Enter A[0][0] :--> 1
Enter A[0][1] :--> 2
Enter A[0][2] :--> 3
Enter A[1][0] :--> 4
Enter A[1][1] :--> 5
Enter A[1][2] :--> 6
Enter A[2][0] :--> 7
Enter A[2][1] :--> 8
Enter A[2][2] :--> 9

The matrix is :-->
1  2  3
4  5  6
7  8  9