< previous page page_702 next page >

Page 702
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
typedef char NameString[21];
typedef char WordString[11];

NameString firstName;
NameString lastName;
WordString word;
mark the following statements valid or invalid. (Assume the header file String.h has been included.)
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
a. i = 0;
  while (firstName[i] != '\0')
  {
      cout << firstName[i];
      i++;
  }
b. cout << lastName;
c. if (firstName == lastName)
       n = 1;
d. if (strcmp(firstName, lastName) == 0)
       m = 8;
e. cin >> word;
f. lastName = word;
g. if (strcmp(NameString, "Hi") < 0)
       n = 3;
h. if (firstName [2] == word[5])
       m = 4;
8. Given the declarations
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
typedef char String20[21];
typedef char String30[31];

String20 rodent;
String30 mammal;
write code fragments for the following tasks. (If the task is not possible, say so.)
a. Store the string "Moose" into mammal.
b. Copy whatever string is in rodent into mammal.
c. If the string in mammal is greater than "Opposum" lexicographically, increment a variable count.
d. If the string in mammal is less than or equal to "Jackal", decrement a variable count.
e. Store the string "Grey-tipped field shrew" into rodent.
f. Print the length of the string in rodent.
9. Given the declarations
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
const int NUMBER_OF_BOOKS = 200;

typedef char BookName[31];
typedef char PersonName[21];

 
< previous page page_702 next page >