Random numbers into 2d array

Apr 10, 2014 at 11:23pm
hi,i am trying to print a 2d (4*4) array,filling it with random numbers,however when i print, all elements are shown as zero. please help

1
2
3
4
5
6
7
8
9
10
11
12
  void print()
{

	for(int rows=0;rows<row;rows++)
	{
		for(int cols=0;cols<col;cols++)

			cout << setw(5) << myArray[rows][cols] << "" ;
		    cout << endl;
	}

}
Apr 10, 2014 at 11:38pm
Is it because you forgot to initialize your array?

Where are you filling your array with random numbers?
Apr 10, 2014 at 11:40pm
i want to initialize my array by means of filling it with random numbers?
Apr 10, 2014 at 11:57pm
You want the user to pick those random numbers or you want the script to pick random numbers, as in srand(time(null)) ?
Apr 11, 2014 at 12:02am
the script....not the user
Apr 11, 2014 at 12:06am
i have managed to figure it out. thanks darqan and seiza
Topic archived. No new replies allowed.