463,663 views
19 votes
19 votes
which of the following initializes an array of 4 doubles called temperatures with the following initial values: 80.2, 65.3, 12.17, 20.21?

User Nerkyator
by
3.1k points

1 Answer

21 votes
21 votes

Answer:

double temperatures[4] = {80.2, 65.3, 12.17, 20.21};

This code creates an array of 4 doubles called temperatures and initializes it with the specified values. The array is declared using the double data type, followed by the name of the array (temperatures) and the size of the array (4) in square brackets. The initial values of the array are specified in curly braces after the = sign.

You can access individual elements of the array using their index in square brackets, starting from 0 for the first element. For example, to access the first element of the temperatures array, you would use the following syntax:

temperatures[0] // this would evaluate to 80.2

Or, to access the third element of the array, you would use the following syntax:

temperatures[2] // this would evaluate to 12.17

It is important to note that arrays in C are zero-indexed, which means that the first element of the array has an index of 0, the second element has an index of 1, and so on.

User Con
by
3.1k points