Problem with Arrays

Discussion in 'C++' started by dldsob, Oct 28, 2009.

  1. dldsob

    dldsob New Member

    Joined:
    Jul 3, 2009
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    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






    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. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,009
    Likes Received:
    203
    Trophy Points:
    63
    Occupation:
    Senior Support Engineer
    Location:
    England
    I would suggest using a printf or cout statement within a for loop.
    e.g.
    Code:
    for (int i=0; i<4; i++)
      printf("%c ",status[i]);
    
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice