Results 1 to 3 of 3
  1. #1
    grace425 is offline Member
    Join Date
    Feb 2013
    Posts
    1
    Rep Power
    0

    Default two dimensional array

    hello.. I'm grace from philippines..

    i was wondering how to make a multiplication table using two dimensional array..
    i've been trying a lot but the output was totally different..

    here is my program... please tell me whats wrong with this.

    #include<stdio.h>
    #include<conio.h>

    int main(){
    int array[5][5]={{1,2,3,4,5},{1,2,3,4,5}};
    int row, col, x;

    for(row=0;row<=5;row++){
    printf("\n %d", array[row]);
    for(col=0;col<=5;col++){
    x=row*col;
    printf("%d", array[x]);
    }
    }
    getch();
    }

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,450
    Rep Power
    18

    Default Re: two dimensional array

    Well, for starters, that's C, not Java.
    Please do not ask for code as refusal often offends.

  3. #3
    AndrewM16921 is offline Senior Member
    Join Date
    Jan 2009
    Location
    NJ, USA
    Posts
    261
    Rep Power
    6

    Default Re: two dimensional array

    Well, for the sake of answering your question in a language independent way:

    First, you initialize the values of the array in a seemingly arbitrary way. Just make an empty array of 5x5 to start.

    Try something along these lines:

    Java Code:
    // NOT JAVA - just put in code tags for the sake of indentation
    for x = 0 to 5
    	for y = 0 to 5
    		array[x][y] = x * y
    
    for x = 0 to 5
    	for y = 0 to 5
    		print array[x][y]

Similar Threads

  1. Two dimensional Array
    By Juukamen in forum New To Java
    Replies: 4
    Last Post: 11-09-2011, 11:10 AM
  2. Help with Two Dimensional Array
    By johnjacob in forum New To Java
    Replies: 2
    Last Post: 06-03-2011, 08:22 PM
  3. 2 dimensional array help!
    By ber1023 in forum New To Java
    Replies: 9
    Last Post: 01-02-2011, 12:29 AM
  4. Two dimensional array
    By niu_niu in forum New To Java
    Replies: 4
    Last Post: 06-13-2010, 12:34 AM
  5. about two dimensional array
    By matin1234 in forum New To Java
    Replies: 2
    Last Post: 06-01-2010, 11:09 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •