Are the following array initializations correct? If not, why not?

a) int x[4] = {8, 7, 6, 5, 4};
b) int x[] = {8, 7, 6, 5, 4};
c) int x[4] = {8, 7, 6};
d) const int SIZE =4;
int x[SIZE];
e) const int SIZE =4;
int x[SIZE-4];


b) int x[] = {8, 7, 6, 5, 4}; , c) int x[4] = {8, 7, 6}; , and
d) const int SIZE =4;
int x[SIZE];

In the correct answer c) the last array item, x[3] is initialized to 0 by
default. The incorrect items: Part a) has too many initializers, part e) attempts to
declare an array of (illegal) size 0.(Array indices range from 0 to
declared_size–1. What could this mean if declared_size is 0?)

Computer Science & Information Technology

You might also like to view...

A stack is a container that allows elements to be stored and removed

A) in a last-in-first-out fashion B) in a first-in-first-out fashion C) last-in-last-out fashion D) according to priority

Computer Science & Information Technology

List two reasons why it may be necessary to hide rows or columns of information in a worksheet

What will be an ideal response?

Computer Science & Information Technology

The Picture password feature of Windows 8 and Windows 8.1 can be enabled if your computer has a touch-enabled device or screen. To use it, you select a picture as the basis; then your _________becomes the basis of your logon authentication

a. Password b. Fingerprint across the picture c. Gestures across the picture d. Double-clicking the picture

Computer Science & Information Technology

The company involved in an attack by Oleg Zezev from Kazahkstan, in which Zezev accessed computer data and copied personal information for purposes of blackmail was ______

a. General Motors b. Interactive Television Technologies, Inc. c. Bloomberg, Inc. d. None of the above

Computer Science & Information Technology