Quiz


1.  

What is the difference between an array element and a variable?

the name of a variable references one memory location. the name of an array references one or multiple memory locations when used in conjunction with an index. if a programmer needs to access multiple variables, the programmer must explicitly specify variable names within the program. if a programmer needs to access multiple elements of array, the programmer can use the array name followed by an index value within a for loop.

2.  

What is an array of pointers?

an array of pointers is an array whose elements store memory addresses of variables or elements of another array.

3.  

How do you assign an address to an element of a pointer array?

you assign a memory address to an element of a pointer array by using the address operator, which is the ampersand (&), in an assignment statement such as ptletters[0] = &letters[2];

4.  

What is an array of pointers to pointers?

an array of pointers to pointers is an array whose elements can store a memory address. this memory address is the memory address of either a pointer variable or an element of a pointer array.

5.  

How do you assign a value to an element of an array of pointers to pointers?

you assign a value to an element of an array of pointers to pointers by using the address operator, as shown here. however, the value must be a memory address of a pointer. ptptletters[0] = & ptletters[0];

6.  

How do you display the contents of the memory addresses stored in an element of a pointer array?

you display the contents of the memory addresses stored in an element of a pointer array by preceding the element with an asterisk, as shown here: cout -- * ptletters[0] -- endl;

7.  

Why would you use an array of pointers to pointers?

you would use an array of pointers to pointers to reorder large amounts of data stored in memory without having to move the data. instead of moving the data, you reorder reference to the data s memory address.

8.  

How do you declare an array?

an array is declared by specifying the data type, array name, and number of elements contained in the array, as shown here: char letters[3];

9.  

How do you display the contents of the memory addresses stored in an element of an array of pointers to pointers?

you display the contents of the memory addresses indirectly referenced in an element of an array of pointers to pointers by preceding the array name with two asterisks, as shown here: cout -- * ptptletters[0] -- endl;

10.  

How are elements of an array stored in memory?

elements of an array are stored sequentially in memory.

Answers

1.  

The name of a variable references one memory location. The name of an array references one or multiple memory locations when used in conjunction with an index. If a programmer needs to access multiple variables , the programmer must explicitly specify variable names within the program. If a programmer needs to access multiple elements of array, the programmer can use the array name followed by an index value within a for loop.

2.  

An array of pointers is an array whose elements store memory addresses of variables or elements of another array.

3.  

You assign a memory address to an element of a pointer array by using the address operator, which is the ampersand (&), in an assignment statement such as

 ptLetters[0] = &letters[2]; 

4.  

An array of pointers to pointers is an array whose elements can store a memory address. This memory address is the memory address of either a pointer variable or an element of a pointer array.

5.  

You assign a value to an element of an array of pointers to pointers by using the address operator, as shown here. However, the value must be a memory address of a pointer.

 ptPtLetters[0] = & ptLetters[0]; 

6.  

You display the contents of the memory addresses stored in an element of a pointer array by preceding the element with an asterisk, as shown here:

 cout << * ptLetters[0] << endl; 

7.  

You would use an array of pointers to pointers to reorder large amounts of data stored in memory without having to move the data. Instead of moving the data, you reorder reference to the data s memory address.

8.  

An array is declared by specifying the data type, array name, and number of elements contained in the array, as shown here:

 char letters[3]; 

9.  

You display the contents of the memory addresses indirectly referenced in an element of an array of pointers to pointers by preceding the array name with two asterisks , as shown here:

 cout << * ptPtLetters[0] << endl; 

10.  

Elements of an array are stored sequentially in memory.




Data Structures Demystified
Data Structures Demystified (Demystified)
ISBN: 0072253592
EAN: 2147483647
Year: 2006
Pages: 90

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net