
550 CHAPTER 8 Single-Dimensional Arrays
EXERCISES,PROBLEMS, AND PROJECTS
else
temp[i] = false;
}
return temp;
}
8.10.3 Fill In the Code
27. This code assigns the value 10 to all the elements of an array a.
int []a = new int[25];
for ( int i = 0; i < a.length; i++ )
{
// your code goes here
}
28. This code prints all the elements of array a that have a value greater
than 20.
double []a = { 45.2, 13.1, 12.8, 87.4, 99.0, 100.1, 43.8, 2.4 };
for ( int i = 0; i < a.length; i++ )
{
// your code goes here
}
29. This code prints the average of the elements of array a.
int []a = { 45, 13, 12, 87, 99, 100, 43, 2 };
double average = 0.0;
for ( int i = 0; i < a.length; i++ )