A two dimensional array can be said to be an array within another array in such away it looks like or forms a table where there is a row and a column. the first array is created and the data within that array is another array

This is a sample on writing two dimensional array with Qbasic its kind of easy all you just need is to understand how it works.

here is the code:

DIM vars(2, 2) AS INTEGER

vars(1, 1) = 1

vars(1, 2) = 1

vars(2, 1) = 2

vars(2, 2) = 2

FOR y = 1 to 2

FOR x = 1 to 2

PRINT vars(y,x),




The first line declares the type of array, it has the word “dim” short for dimension and the name of the array which in this case is vars.

The numbers in the bracket specifies what type of array you want. If it is a single or one dimensional array, you enclose the total number of items in that array in a bracket for example studentsAge(40) means the array “studentsAge will have fourty (40) spaces for inserting fourty (40) different ages.

For a two dimensional array, its a little bit different. You need to specify the number of rows and columnsĀ  in the format (num of rows, num of cols). example of a two dimensional array is a 2 x 2 array given in the question above. Which shows (2, 2) meaning this array will have two rows and two colums

The second line to the forth line initializes the array. i.e it gives value to the array starting from the first column to the last column from top to bottom , left to right

the the last lines print the arrays to the screen.

Please feel free to comment and like our page on facebook


Gosh, I wish I would have had that inoirmatofn earlier!

clipping path

Really nice post here for Multi dimensional array using basic program. Thanks


I’m so glad I found my souliton online.


Very nice and wonderful News to have here on dimconnect.com website

Leave a Reply

Your email address will not be published. Required fields are marked *

Like us