Picking the array

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Learner21
    New Member
    • Mar 2008
    • 9

    Picking the array

    I can't seem to understand how I can get the program to put down the column instead of the row. Here is my program as of now:


    case 'b':
    case 'B':
    if (Work_ID >=1 || Work_ID <= 4)
    {

    cout << "Please enter the worker ID: ";
    cin >> Work_ID;
    cout << "What day do you want the report end on? ";
    cin >> Day;

    cout << " Individual report: \n";
    cout << name[Work_ID-1];
    Work_ID = 0;
    for(k =0; k < Day ; k++)
    {

    cout << work_hours[Day-1][k];
    cout << " \n"<<"\n";
    }
    }



    What it was suppose to do was display the column array after i have displayed the name array. basically like this:

    Please enter your selection : B


    Please enter the student ID : 1


    What day do you want the report to end on? 3


    Individual report:

    Mary Johnson : 4 3 4

    but I got this output:



    Mary Johnson: 5 5

    Everything is correct above it except that, I wanted to read 4 3. What should I do?

    Thanks
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    Originally posted by Learner21
    if (Work_ID >=1 || Work_ID <= 4)
    Let's see:
    1) if WORK_ID is -256 then it is <=4. Your expression is TRUE.
    2) if WORK_ID is 256 then it is >=1. Your expression is TRUE.
    3) if WORK_ID is 3 then it is >=1. Your expression is TRUE.

    etc...

    Maybe you meant &&?

    Comment

    • whodgson
      Contributor
      • Jan 2007
      • 542

      #3
      ......i think,
      The first if( ) statement can`t be evaluated because WORK_ID value is unknown. cin>>WORK_ID should preceed it.

      Comment

      Working...