PAGETURNER
BOX
REVIEW
GO
Which of the following statements is/are TRUE?
1. An array may hold structures of various types.
2. A structure may nest other structures.
3. An array of pointers to 200 structures of
30 bytes requires five times more space
than an array of pointers to 200 strings of
5 characters each.
4. The C cast is useful for changing
the variable type.
a) 1 and 4. b) 2,3 and 4. c) 2 and 4. d) 3 and 4.
Select One:
That is correct!
You've got it on the 2nd try.
You've got it finally!
Sorry, Try Again.
NO, Try one more time
Please Review Array of Pointers and Casting.
FORGET1
The correct choice is c. Statement 1 is wrong because an
array may not hold variables of various types. Statement
3 is wrong because an array of pointers to the same number of
objects of any type always takes up the same space.
The declaration that would do the most efficient
allocation of space for the addresses of five
floating point arrays of 20 characters each
would be:
a) char *ar[5];
b) int ar[5][20];
c) char ar[5][20];
d) char *ar[5][20];
Select One:
That is correct!
You've got it on the 2nd try.
You've got it finally!
Sorry, Try Again.
NO, Try one more time
Please Review the section on Arrays of Pointers!
FORGET2
The correct choice is a, because we're interested
in storing addresses only. Other choices either
allocate wrong types or allocate too much space!
To allocate the space for an array of 20
consecutive integers, which statement would
you use if you also wanted to have a pointer
to the allocated area, given the variables:
int *x; float *y; char *z;
a) x = malloc ( 20 );
b) y = malloc (unsigned(20));
c) z = (char *) malloc(20);
d) x = (int *) malloc (unsigned (20) );
Select One:
That is correct!
You've got it on the 2nd try.
You've got it finally!
Sorry, Try Again.
NO, Try one more time
Please Review Dynamic Allocation and the function malloc()!
FORGET3
The correct choice is d. Choices b and c
give wrong types. Choice a assigns an address
of a character string to a pointer to an integer.
Therefore, d is the obvious choice.