2D Arrays Homework Help

This is a discussion on 2D Arrays Homework Help within the C Programming forums, part of the General Programming Boards category; Hello, I have most of the code working properly, but I'm having trouble with a certain area. Currently I have ...

  1. #1
    Registered User
    Join Date
    Mar 2013
    Posts
    2

    2D Arrays Homework Help

    Hello, I have most of the code working properly, but I'm having trouble with a certain area. Currently I have multiple 2D arrays. One is a char array and the other is an int array. In the int array I have to find the max number in each column, which I've done. The problem is, I need to print the max number's row in relation to the char array's row.

    For example,
    Code:
    int array[2][3] = 
    {60 50 30
    0 100 1}
    
    The max numbers are 60, 100, 30. 
    
    char array[2][length+1] = 
    {nameOne
    nameTwo}
    
    How it needs to print: 
    nameOne has max score of 60.
    nameTwo has max score of 100.
    nameOne has max score of 30.
    I just can't understand how to compare the two arrays in the right way, so it'll know that nameOne is associated with the numbers in row 0 and nameTwo in row 1, etc. I hope this makes sense, if anyone can point me in the right direction, that would be great! Thanks

  2. #2
    SAMARAS std10093's Avatar
    Join Date
    Jan 2011
    Location
    Nice, France
    Posts
    2,694
    When on i-th column at the int array, you need to reference the i-th row from the char array. When the i-th row from the char array reaches the 1st dimension of the char array (that is in your example 2), reinitialize i for the char array to zero.
    Code - functions and small libraries I use


    It’s 2014 and I still use printf() for debugging.


    "Programs must be written for people to read, and only incidentally for machines to execute. " —Harold Abelson

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. homework help - arrays (I think)
    By foxhenchman in forum C Programming
    Replies: 4
    Last Post: 03-26-2011, 02:00 AM
  2. entry level homework help: Passing Arrays into functions.
    By DHart07 in forum C++ Programming
    Replies: 8
    Last Post: 04-21-2010, 09:11 AM
  3. Replies: 16
    Last Post: 01-01-2008, 03:07 PM
  4. Homework problem...structures or arrays?
    By tortan in forum C++ Programming
    Replies: 21
    Last Post: 08-30-2006, 01:26 AM
  5. Replies: 2
    Last Post: 02-23-2004, 05:34 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21