#include #include #include //for string using namespace std; struct month { int length; //number of days string name; }; int main() { month a[] = { {31, "January"}, {28, "February"}, {31, "March"}, {30, "April"}, {31, "May"}, {30, "June"}, {31, "July"}, {31, "August"}, {30, "September"}, {31, "October"}, {30, "November"}, {31, "December"} }; const size_t n = sizeof a / sizeof a[0]; cout << "Length and name of each month:\n"; int sum = 0; for (month *p = a; p < a + n; ++p) { cout << p->length << " " << p->name << "\n"; sum += p->length; //means sum = sum + p->length } cout << "\n"; cout << "A year has " << sum << " days.\n"; return EXIT_SUCCESS; }