Suppose you have the following array declaration in a program.
int yourArray[5];
Further suppose that in the implementation of C++ you are using an int that requires 4 bytes.
i) When your program runs, how much memory is required for this array?
ii) Suppose further that your array starts at memory location decimal 100 . What will be the address of yourArray[3]?
iii)If you wrote to the (illegal) index 7 position in yourArray to what address would this clobber?

a. i) The array takes 5 bytes, ii) yourArray[3] will be an int located at Address 103 . iii) writing to yourArray[7] will clobber an int starting at location 107.

b. i) The array takes 10 bytes, ii) yourArray[3] will be an int located at Address 106 . iii) writing to yourArray[7] will clobber an int starting at location 114
c. i) The array takes 20 bytes, ii) yourArray[3] will be an int located at Address 112 iii) writing to yourArray[7] will clobber an int starting at location 128
d. The purpose of a high level language is to insulate the programmer from these details. It isn’t possible to know this without probing the source to the operating system and the compiler, or extensive debugging.


c) is correct.
Explanation a) would be correct for a 1 byte int, b) would be correct for a 2 byte int (older MS DOS and MS Windows systems.) d) is an answer appropriate to a language that does not provide low level access (e.g. Java.)

Computer Science & Information Technology

You might also like to view...

Match the following terms to their meanings:

I. Data validation rule II. Error alert III. Macro IV. Protect sheet V. Shared workbook A. Data validation message indicating that invalid data has been entered B. Places a restriction on the types of data that can be entered into cells C. Stored set of instructions to automate a task D. Prevents unauthorized users from making changes to a worksheet E. Workbook in which multiple users can make changes at the same time

Computer Science & Information Technology

The 2.5" size hard drive is typically used in devices such as MP3 players.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology

If you assign different user names for each user of your computer, the operating system creates a special ________ for each user.

a. profile b. network c. disk drive d. email account

Computer Science & Information Technology

Web pages are ____ files containing hypertext markup language (HTML) directives and textual information.

A. text B. binary C. animated D. executable

Computer Science & Information Technology