Square Matrix Program
#include <stdio.h>
int main()
{
int n, r, c;
printf("Enter order: ");
scanf("%d", &n);
int myarr[n][n]; //n rows and n columns
printf("Enter the elements below:\n");
printf("");
for (r = 0; r < n; r++)
{
for (c = 0; c < n; c++)
{
scanf("%d", &myarr[r][c]);
}
}
// display of matrix
printf("------------Your required Matrix------------\n");
for (r = 0; r < n; r++)
{
for (c = 0; c < n; c++)
{
printf("%d ", myarr[r][c]);
}
printf("\n");
}
return 0;
}
// Programmer: TEJAS
Output

Comments
Post a Comment