0

i have a 2D array of emp[20][10]

How can i do it such that it only prints out the selected index like emp[0][0] to emp[0][10] etc.

It will print around more than the selected..

for(int i= 0; i < 20; i++) 
{
    for (int j = 0; j < 10; j++) 
    {
        emp[0][j].viewEMP();
    }
}
2
Contributors
3
Replies
5
Views
8 Years
Discussion Span
Last Post by seanhunt
0

i have a 2D array of emp[20][10]

How can i do it such that it only prints out the selected index like emp[0][0] to emp[0][10] etc.

It will print around more than the selected..

for(int i= 0; i < 20; i++) 
{
    for (int j = 0; j < 10; j++) 
    {
        emp[0][j].viewEMP();
    }
}

well, for [0][0] to [0][9] (bear in mind that arrays start at 0) you would just have the one loop:

for( int i = 0; i < 10; i++ ){
	emp[0][i].viewEMP();
}

Sean

0

so it is possible to remove for line 3 from my post => (int i= 0; i < 20; i++)

I need to code it in a view function
May i know what parameter to pass in ?

void Display(Employee emp, int size, int index)
{
          for( int i = 0; i < size; i++ ){
	emp[index][i].viewEMP();

}
0

Well, I'm not sure what the array has in it. or what the application is doing, but given the function, yes. You left out a closing brace at the end of the for loop. This actually is C stuff, not C++, so you might want to post there for matters like this.

Thanx...
Sean

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.