-1

Can someone tell me why my second column is not the square of the fist? Here is what I have:

const int NUM_ROWS = 10;
const int NUM_COLS = 2;

int[,] randint = new int [NUM_ROWS,NUM_COLS];
Random randNum = new Random();

for (int row = 0; row < randint.GetLength(0); row++)
{
    randint[row,0] = randNum.Next(1,100);
    randint[row,1] = randint[row,0]*randint[row,0];

Console.Write(string.Format("{0,5:d} {0,5:d}\n", randint[row,0], randint[row,1]));
Cœur
  • 37,241
  • 25
  • 195
  • 267
KBS
  • 13
  • 1
  • 2

1 Answers1

1

It is. You're only printing the first number to the console. Your string format should be "{0,5:d} {1,5:d}\n"

Preston Guillot
  • 6,493
  • 3
  • 30
  • 40