Thread: Two dimensional arrays

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    May 2004
    Posts
    6

    Two dimensional arrays

    Hi there guys, im new to the forum.

    Currently a first year programming student, and struggling on arrays as i missed a lecture. Here's what i need to do, and what ive done, before i hit my point of not knowing any more.

    Im trying to write a program that will read this data into a 2 dimensional array (data is 1,2,3,4,5,6,7,8,9) so, i've used this

    Code:
    int arr[3][3]={
                   {1,2,3},
                   {4,5,6},
                   {7,8,9}
                   };
    then ive used

    Code:
    int i,j;
    
    	for (i=0;i<3;++i)
       {
       	for(j=0;j<3;++j)
       	printf("%d",arr[i][j]);
          	printf("\n");
       }
    to make the program produce the data into a nicely formatted array

    1 2 3
    4 5 6
    7 8 9

    Which so far is correct, and working.
    Now i need to have the add the value's within the columns, and have them output a lower total, and a side total. What i mean is,


    Code:
    1   2   3| 6   
    4   5   6| 15
    7   8   9| 24
    ==========
    12  15  18
    Im stumped as to how i do this, and my text book only tells me so much, please, i hope you can help me!

    MANY THANKS,

    Masschino
    Last edited by Masschino; 05-18-2004 at 06:02 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Pointers and multi dimensional arrays
    By andrea72 in forum C++ Programming
    Replies: 5
    Last Post: 01-23-2007, 04:49 PM
  2. Dynamic two dimensional arrays
    By ThWolf in forum C++ Programming
    Replies: 14
    Last Post: 08-30-2006, 02:28 PM
  3. passing two dimensional arrays
    By Nova_Collision in forum C++ Programming
    Replies: 3
    Last Post: 02-04-2003, 01:47 PM
  4. two dimensional arrays
    By ssjnamek in forum C++ Programming
    Replies: 4
    Last Post: 05-01-2002, 08:12 PM
  5. Two dimensional arrays
    By Jax in forum C Programming
    Replies: 1
    Last Post: 11-07-2001, 12:53 PM