// create an array of 10 doubles const int ArrSize = 10; double myArray[ArrSize]; |
// create and initialize an array of 3 floats
const int ASize = 3;
float arr[ASize] = { 10.5, 6.123, 3.14 };
|
myArray[4] = 1.0; // put the value one in array position 4 |
float x = arr[1]; // copy a value from array position 1 to variable x |
// put the value 0.5 in each position of the array
for (int pos = 0; pos < ArrSize; pos++) {
myArray[pos] = 0.5;
}
|
// prototype for a function to print the contents of an array void printArray(double arr[], int size); // ... suitable call to the function from somewhere inside main printArray(myArray, ArrSize); |