Which of these array definitions will set all the indexed variables to 0?
a) int array[5];
b) int array[5] = {0};
c) int array[5] = {0,1,2,3,4};
d) int array[5] = {0,0,0};x
>>What is the x?
e) int array[5] = {0,0,0,0,0};x
>>What is the x?
b) int array[5] = {0}; ,
d) int array[5] = {0,0,0};x
>>What is the x?
and
e) int array[5] = {0,0,0,0,0};x
>>What is the x?
b) and d) explicitly initialize some of the indexed variables to 0. The rest are automatically set to 0. Part a) leaves the indexed variables with garbage in them. Part c) sets array[0] to 0, array[1] to 1, array[2] to 2, etc.
You might also like to view...
Which one of the following statements correctly declares a reference variable named values that can be used to reference an array of int?
a. int values[]; b. values[int]; c. int[] values; d. int [values];
Suppose that a text file text.txt contains an unspecified number of scores. Write a program that reads the scores from the file and displays their total and average. Scores are separated by blanks.
What will be an ideal response?