Problem with Arrays

This is a discussion on Problem with Arrays within the C++ Programming forums, part of the General Programming Boards category; I declared 4 different arrays. I dont know how to display all the arrays. Can anyone please help me with ...

  1. #1
    Registered User
    Join Date
    Jul 2009
    Posts
    7

    Problem with Arrays

    I declared 4 different arrays. I dont know how to display all the arrays. Can anyone please help me with this? I want to display all 4 arrays like this:


    Student 1 2 3 4 5 6 7 Time Status Final

    1 0 0 0 0 0 0 0 6.50 B 0
    2 5 6 7 8 2 1 3 4 C 0
    3 0 0 0 0 0 0 0 7.50 B 0
    4 3 4 5 1 2 9 4 12 A 0


    Code:
    int main()
    {
        const int NUM_STUDENT = 4;
        const int NUM_QUIZ = 7;
        int student = 0;
        int quiz = 0;
        double grade[NUM_STUDENT][NUM_QUIZ] = {{0, 0, 0, 0, 0, 0, 0},
                                                {5, 6, 7, 8, 2, 1, 3},
                                                {0, 0, 0, 0, 0, 0, 0},
                                                {3, 4, 5, 1, 2, 9, 4}};
        
        double time[4] = {9, 10.5, 10.5, 12};
        char status[4] = {'B', 'C', 'B', 'A'};
        double final [4] = {0, 0, 0, 0};
    }

  2. #2
    Registered User
    Join Date
    Jan 2005
    Posts
    7,319
    You just need a loop or two. Start by outputting the header. Then write the code to output the student number (1, 2, 3 and 4) each on its own line. Make sure you compile and test to verify what you have is working. Then keep doing something else one step at a time. When you get stuck with a specific step, you can ask for more help.

    Do you know which type of loop you should use?

  3. #3
    Registered User
    Join Date
    Jul 2009
    Posts
    7
    I know I have to use for loop for that but I don't know how to use for loops to display all arrays.

  4. #4
    a_capitalist_story
    Join Date
    Dec 2007
    Posts
    2,650
    Ah yes, the dreaded forum cross-poster.

    Pick one and stick with it. Don't be rude.

  5. #5
    Registered User
    Join Date
    Jan 2005
    Posts
    7,319
    >> I don't know how to use for loops to display all arrays.
    Do you know how to use a for loop to display one array? Do you know how to display one item in one array without a loop? Start with what you know and work from there.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help with a problem regarding dynamic memory and arrays
    By Michty in forum C++ Programming
    Replies: 5
    Last Post: 07-26-2006, 01:26 PM
  2. assignment of arrays problem
    By HumbuckeR in forum C++ Programming
    Replies: 4
    Last Post: 04-13-2006, 04:25 PM
  3. Problem with arrays
    By dogbert234 in forum C++ Programming
    Replies: 2
    Last Post: 03-25-2006, 02:06 AM
  4. Need Help With 3 Parallel Arrays Selction Sort
    By slickwilly440 in forum C++ Programming
    Replies: 4
    Last Post: 11-19-2005, 09:47 PM
  5. Problem with character arrays in classes
    By spoketoosoon in forum C++ Programming
    Replies: 3
    Last Post: 03-16-2004, 02:57 AM

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