Chapter 4

A1:
  1. char actors[30];

  2. short betsie[100];

  3. float chuck[13];

  4. long double dipsea[64];

A2: int oddly[5] = {1, 3, 5, 7, 9};
A3: int even = oddly[0] + oddly[4];
A4: cout << ideas[1] << "\n"; // or << endl;
A5: char lunch[13] = "cheeseburger"; // number of characters + 1

or

char lunch[] = "cheeseburger"; // let the compiler count elements

A6: [click here]
struct fish {
    char kind[20];
    int weight;
    float length;
};
A7:
fish petes =
{
    "trout",
    13,
    12.25
};
A8: enum Response {No, Yes, Maybe};
A9:
double * pd = &ted;
cout << *pd << "\n";
A10:
float * pf = treacle;   // or = &treacle[0]
cout << pf[0] << " " << pf[9] << "\n";
            // or use *pf and *(pf + 9)
A11:
 unsigned int size; cout << "Enter a positive integer: "; cin >> size; int * dyn = ...

Get The Waite Group's C++ Primer Plus, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.