The illustration shows code segment with "Explicitly Nested Loops." The lines numbered 10 through 46 are as follows:
<< "Each conservationist's report consists of\n"
<< "a list of numbers. Each number is the count of\n"
<< "the eggs observed in one"
<< "green-necked vulture nest.\n"
<< "This program then tallies
<< "the total number of eggs.\n";
int numberOfReports;
cout << "How many conservationist reports are there? ";
cin >> numberOfReports;
int grandTotal = 0, subtotal, count;
for (count = 1; count <= numberOfReports; count++)
{
cout << endl << "Enter the report of "
<< "conservationist number " << count << endl;
cout << "Enter the number of eggs in each nest.\n"
<< "Place a negative integer at the end of your list.\n";
subtotal = 0;
int next;
cin >> next;
while (next >= 0)
{
subtotal = subtotal + next;
cin >> next;
}
cout << "Total egg count for conservationist "
<< " number " << count << " is "
<< subtotal << endl;
grandTotal = grandTotal + subtotal;
}
cout << endl << "Total egg count for all reports = "
<< grandTotal << endl;
return 0;
}
The statements numbered 22 through 41 are boxed. The statements 31 through 36 are also boxed within the larger box.