Tuesday, 23 September 2014

Example of a two dimensional array using basic program (QBASIC)

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),
    NEXT x
    PRINT
NEXT y


The first line declares the type of array you want to make like in this case, its a 2 x 2 array.
The second line to the forth line initializes the array. i.e it gives value to the array the the last lines print the arrays to the screen.
Please feel free to comment and like our page on facebook

4 comments:

  1. you can ask questions if you don't understand any line of code. Thanks

    ReplyDelete
  2. 1.wap to read names and total marks of 10 students.print names and marks for all those students who have scored greater than or equal to 450?
    2. wap to input serial number,name and marks in 5 different subject of any 10 students and print the name and marks of highest scorer.
    3.wap to read name and mobile number of any 10 students from given data statement.ask the user to input a name and print his/her mobile number.
    I need these question's answer ASAP can you help me through out this ?? ASAP

    ReplyDelete
  3. Write a BASIC program that determines and prints the smallest and largest elements of a two-dimensional array (assuming that it; has been already inputted) with four rows and five columns.

    ReplyDelete
  4. Using Double Dimensional Array give the following outputs:

    A B C

    D E

    ReplyDelete