while (j < i)
 {
     cin.ignore();
     cout << "Please type enter to display: ";
     cin >> enter2;
     
     if (strcmp(enter, enter2) == 0)
     {
         cout <<  "ID: " << students[j].ID << endl;
         cout << "Name: " <<students[j].name << endl;
         cout << "Address: " <<students[j].address << endl;
         cout << "Telephone: " <<students[j].telephone << endl << endl;
         j++;
     }
 }
 j = 0;

Program will display all students’ information in tabular form. Display 2 students at any one time. When user types <enter>, program then display the next 2 students,
until all students are displayed.

I'm suppose to display 2 students at 1 go, wait for user to type enter then display the other 2 students.
The problem is that I'm stuck with this particular part.
If I put
for (int z = 0; z < 2; z++)
Then there would be a problem if my array has an odd number. Hmmm what to do...

Recommended Answers

All 3 Replies

> for (int z = 0; z < 2; z++)
Simply add for (int z = 0; z < 2 && j < i ; z++)

Aaaa, thanks! Didn't use much of the && and || for loops :D

ex. of looping,.?
hellppp,.?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.