Sara Molavi Sara Molavi - 1 year ago 118
C# Question

printing matrix square shape c#

I have an 8*8 matrix and here is my code:

static void Main(string[] args)
const int matrix_rows = 8;
const int matrix_columns = 8;
double[,] matrix = new double[matrix_rows, matrix_columns];
for (int i = 0 ; i < matrix_rows ; i++)
for (int j = 0; j < matrix_columns; j++)

Console.WriteLine(matrix[i, j]+ "\t");


I want it to be printed square shape but it prints one "0" in each line. what should I do?

Answer Source

You write a new line each time. Do Console.Write() instead of Console.WriteLine()

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download